您好我需要构建一个DB2 / SQL查询,以便知道相应时间戳的项目总数。
Date Item
01/08/2014 05:53 request 1
02/08/2014 05:53 request 1
03/08/2014 05:53 request 1
01/08/2014 06:32 request 2
02/08/2014 06:32 request 2
03/08/2014 06:32 request 2
01/08/2014 06:38 request 3
02/08/2014 06:38 request 3
03/08/2014 06:38 request 3
04/08/2014 06:38 request 3
05/08/2014 06:38 request 3
我希望以这种方式输出:
Date Item No of Occurences
01/08/2014 05:53 request 1 3
01/08/2014 06:32 request 2 3
01/08/2014 06:38 request 3 5
先谢谢!!
答案 0 :(得分:1)
在分组中包括日期:
SELECT Date, Item, count(*) as "No of Occurrences"
FROM <tablename>
GROUP BY Date, Item
答案 1 :(得分:0)
使用GROUP BY
和COUNT
SELECT Date, Item, Count(*) "No of Occurences"
FROM <Table>
GROUP BY Item