raunaqmathur / google-visualization-java

Automatically exported from code.google.com/p/google-visualization-java
0 stars 0 forks source link

order by column id not working with functions in a select #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a mySQL table with the following definition:

id: BIGINT
date: DATE
impressions: BIGINT

The query "select toDate(day), sum(impressions) group by day" gives the 
following results:

google.visualization.Query.setResponse({"version":"0.6","status":"ok","sig":"147
1412089","table":{"cols":[{"id":"toDate_day","label":"toDate(day)","type":"date"
,"pattern":""},{"id":"sum-impressions","label":"sum 
impressions","type":"number","pattern":""}],"rows":[{"c":[{"v":new 
Date(2012,0,27)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,0,28)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,0,29)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,0,30)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,1,1)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,1,2)},{"v":1.0}]},{"c":[{"v":new 
Date(2012,1,3)},{"v":1.0}]},{"c":[{"v":new Date(2012,1,4)},{"v":1.0}]}]}});

As you can see it's given the toDate(day) column the id "toDate_day"

However, trying the following query: select toDate(day), sum(impressions) group 
by day order by `toDate_day`

Gives the invalid query error:

Column [`toDate_day`] which appears in ORDER BY, must be in SELECT as well, 
because SELECT contains aggregated columns.

This should order by toDate(day) as you can according to the documentation give 
a column ID in an order by.

I'm using version 1.1.1

Original issue reported on code.google.com by r...@somoglobal.com on 15 Feb 2012 at 6:30