基本上我有一个与此类似的表:
time.....activities.....length 13:00........3.............1 13:15........2.............2 13:00........3.............2 13:30........1.............1 13:45........2.............3 13:15........5.............1 13:45........1.............3 13:15........3.............1 13:45........3.............2 13:45........1.............1 13:15........3.............3
一些注意事项:
查询应返回:
time........count 13:00.........2 13:15.........2 13:30.........0 13:45.........1
基本上,对于每个唯一时间,我都希望对活动值为3的行数进行计数。
所以我可以说:
At 13:00 there were X amount of activity 3s. At 13:45 there were Y amount of activity 3s.
然后我要对活动1s,2s,4s和5s进行计数。因此我可以绘制每个不重复时间的分布图。
是的,您可以使用GROUP BY:
GROUP BY
SELECT time, activities, COUNT(*) FROM table GROUP BY time, activities;