After some digging, it turns out that Fusion Tables don't support ordering 
data by multiple columns.  Here's the feature request to add the 
capability: http://code.google.com/p/fusion-tables/issues/detail?id=584; 
you can "star" the issue to get updates on it.

All is not lost, though, as the API supports sorting your data on the 
client side.  Use the 
#getSortedRows<https://developers.google.com/chart/interactive/docs/reference#DataTable_getSortedRows>method
 to get a list of the sorted row indices, or use the 
#sort<https://developers.google.com/chart/interactive/docs/reference#DataTable_sort>method
 to permanently sort the data in the DataTable.  I attached your code 
using examples of both methods.

On Friday, February 1, 2013 2:17:30 PM UTC-5, [email protected] wrote:
>
> Attached script builds and execute 2 queries (i listed them below).
> The first one works but the second doesn't.
> The only difference is added order by clause.
>
> For simplicity I have included full urls (from debugger):
>
> 1. 
> http://www.google.com/fusiontables/gvizdata?tq=select%20airportcode%20as%20'Airport'%2C%20rehabyear%20as%20'Year'%2C%20rehab%20as%20'Capital%20Plan'%2C%20sum(rehabcost)%20as%20'Cost'%20from%201QJuHSpcAPgtU62DY5UGTjRnUWa90p6obhelV3fA%20where%20airportcode%3D'BOS'%20and%20rehabyear%3E0%20group%20by%20airportcode%2C%20rehabyear%2C%20rehab
>
> 2.http: //
> www.google.com/fusiontables/gvizdata?tq=select%20airportcode%20as%20'Airport'%2C%20rehabyear%20as%20'Year'%2C%20rehab%20as%20'Capital%20Plan'%2C%20sum(rehabcost)%20as%20'Cost'%20from%201QJuHSpcAPgtU62DY5UGTjRnUWa90p6obhelV3fA%20where%20airportcode%3D'BOS'%20and%20rehabyear%3E0%20group%20by%20airportcode%2C%20rehabyear%2C%20rehab%20order%20by%20airportcode%2C%20rehabyear%2C%20rehab
>
>
> On Wednesday, January 30, 2013 1:59:38 PM UTC-5, [email protected]:
>>
>> Here is a query and a parser error I'm getting when passing query that is 
>> using multiple columns in Group By and also using Order By:
>>
>> Query:
>>
>> select airportcode as 'Airport', rehabyear as 'Year', rehab as 'Capital 
>> Plan', sum(rehabcost) as 'Cost' from 
>> 1QJuHSpcAPgtU62DY5UGTjRnUWa90p6obhelV3fA where airportcode='BOS' and 
>> rehabyear>0 group by airportcode, rehabyear, rehab order by airportcode, 
>> rehabyear, rehab
>>
>> Error:
>> google.visualization.Query.setResponse({version:'0.5',reqId:'0',status:'error',errors:[{reason:'internal_error',
>>  
>> message:'Could not parse query'}]})
>>
>>
>> However using the same query without Order By works fine.
>> i.e.
>> select airportcode as 'Airport', crackrepair as 'Crack Repair', 
>> sum(crackrepair_length) as 'Length (ft)' from 
>> 1QJuHSpcAPgtU62DY5UGTjRnUWa90p6obhelV3fA where airportcode='BOS' and 
>> crackrepair_length>0 group by airportcode, crackrepair 
>>
>> Bogdan
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Title: Visualization API Sample


Reply via email to