我想得到一个事件中的所有坐标(有eventId)根据user_id对它们进行分组然后按照时间降序排列每个坐标集并取顶部。(最后更新的坐标)..我试过这个查询。
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;
它给了我这个错误:
{
"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: []"
}
}
答案 0 :(得分:0)
user_id可以有多个位置 - 时间组合...
您有两种可能性:
GROUP BY user_id, Location, Time
或SELECT user_id, min(Location), min(Time) FROM ... GROUP BY user_id