现在表中的输出对于香蕉总数是正确的,但对于绿色香蕉,则是每天的总数。我希望将这两种香蕉每天的总和分组。
while (iterator_1.hasNext())
{
JSONObject obj = (JSONObject) iterator_1.next()l
System.out.println(obj.get("latitude")+" , "+obj.get("longitude"));
System.out.println("\n");
}
答案 0 :(得分:0)
使用条件聚合:
SELECT bananas, date,
SUM( bananas = 'green' ) as green_bananas,
COUNT(bananas) AS total_bananas
FROM banana_table
GROUP BY date;