从表中计算出现次数

时间:2015-06-15 19:42:09

标签: count

这是我的表...我需要计算每个日期最后一列的实例。

所以基本上需要

date                     Count
2015-02-02               8
2015-02-03               10


2015-02-02  01:30:00 PM             1
2015-02-02  02:30:00 PM             1
2015-02-02  03:30:00 PM             1
2015-02-02  05:30:00 PM             1
2015-02-02  06:30:00 PM             1
2015-02-02  08:30:00 AM             1
2015-02-02  09:30:00 AM             1
2015-02-02  11:30:00 AM             1
2015-02-03  01:30:00 PM             2
2015-02-03  02:30:00 PM             2
2015-02-03  03:30:00 PM             2
2015-02-03  04:30:00 PM             2
2015-02-03  05:30:00 PM             2
2015-02-03  06:30:00 PM             2
2015-02-03  08:30:00 AM             2
2015-02-03  09:30:00 AM             2
2015-02-03  10:30:00 AM             2
2015-02-03  11:30:00 AM om          2
2015-02-04  01:30:00 PM             3
2015-02-04  02:30:00 PM             3
2015-02-04  03:30:00 PM             3
2015-02-04  05:30:00 PM             3
2015-02-04  06:30:00 PM             3
2015-02-04  08:30:00 AM             3
2015-02-04  09:30:00 AM             3
2015-02-04  10:30:00 AM             3
2015-02-04  11:30:00 AM             3
2015-02-05  01:30:00 PM             4
2015-02-05  02:30:00 PM             4
2015-02-05  03:30:00 PM             4
2015-02-05  04:30:00 PM             4
2015-02-05  05:30:00 PM             4
2015-02-05  06:30:00 PM             4
2015-02-05  08:30:00 AM             4
2015-02-05  09:30:00 AM             4
2015-02-05  10:30:00 AM             4
2015-02-05  11:30:00 AM             4
2015-02-06  01:30:00 PM             5
2015-02-06  02:30:00 PM             5
2015-02-06  08:30:00 AM             5
2015-02-06  09:30:00 AM             5
2015-02-06  10:30:00 AM             5
2015-02-06  11:30:00 AM             5

1 个答案:

答案 0 :(得分:0)

select DATE(datecolumn) as thedate, count(lastcol) from sometable group by thedate

类似的问题:https://stackoverflow.com/a/366610/636077