我有以下表结构
------------------------------------------
banner_id Date banner_action
------------------------------------------
1 | 01-01-2011 | 1
1 | 01-01-2011 | 2
1 | 01-01-2011 | 3
1 | 02-01-2011 | 1
1 | 02-01-2011 | 1
1 | 02-01-2011 | 1
2 | 02-01-2011 | 2
2 | 01-01-2011 | 1
3 | 01-01-2011 | 1
我想选择所有不同的日期,然后想要为banner_id = 1计算相同的banner_action
答案 0 :(得分:1)
SELECT Date, COUNT(banner_action)
FROM table
WHERE banner_id = 1
GROUP BY Date
答案 1 :(得分:0)
像这样的事情,我不完全确定你想从问题中得到什么。
我假设您的表名为bannerActions
SELECT
Date
,banner_action
,count(Date) actionCount
FROM
bannerActions
GROUP BY
Date
,banner_action
,banner_id
HAVING
banner_id = 1