我正在尝试按日分组,并需要一些帮助(或多组声明?)。该表看起来像:
location timestamp traffic
1 US 2018-01-31 155
2 EU 2018-01-31 574
3 US 2018-01-30 149
4 EU 2018-01-30 150
5 US 2018-01-30 100
我想回来:
location timestamp traffic
1 US 2018-01-31 155
2 EU 2018-01-31 574
3 EU 2018-01-30 150
5 US 2018-01-30 294 --(summed row)
有什么建议吗?
答案 0 :(得分:0)
您可以按多列进行分组:
SELECT location, timestamp, SUM(traffic)
FROM mytable
GROUP BY location, timestamp