I want to get all the coordinates in a event(having eventId) group them according to the user_id then Order each coordinate set according to time in descending order and take the top.(the last updated coordinate).. I tried this query.
var query3 = "https://www.googleapis.com/fusiontables/v2/query?sql=SELECT user_id,Location,Time FROM "+tableID+" WHERE event_id = 23"+" GROUP BY user_id ORDER BY Time DESC LIMIT 1"+"&key="+apiKey;
It gave me this error :
{
"error": {
"errors": [
{
"domain": "fusiontables",
"reason": "badQueryCouldNotParse",
"message": "Invalid query: (col2, LOCATION) must appear in group-by when aggregates are present: []",
"locationType": "parameter",
"location": "q"
}
],
"code": 400,
"message": "Invalid query: (col2, LOCATION) must appear in group-by when aggregates are present: []"
}
}
There can be more than one location - time combination for a user_id...
You have 2 possibilities:
GROUP BY user_id, Location, Time
, orSELECT user_id, min(Location), min(Time) FROM ... GROUP BY user_id