我想显示每天的结果数量(登录次数)。我的查询问题是它返回错误的值。我认为问题在于分组。有人知道问题出在哪里吗?
同样logaction
行可以包含1-4中的数字,所以我想计算每天1,2,3和4中有多少行。
以下是我正在使用的代码:
SELECT username, DATE( Vrijeme) AS Datum, COUNT( logaction ) AS total
FROM user_login_action
WHERE DATE( Datum ) >= '2015-04-06'
AND DATE( Datum ) <= '2015-04-12'
AND username != ''
GROUP BY DATE( Datum ) , username
答案 0 :(得分:3)
您的查询中存在以下问题:
DATE(Vrijeme) AS Datum
后SELECT
DATE(Datum)
,WHERE
和GROUP BY
使用SELECT
username,
DATE(Vrijeme) AS Datum,
COUNT( logaction ) AS total
FROM
user_login_action
WHERE
DATE(Vrijeme) >= '2015-04-06'
AND
DATE(Vrijeme) <= '2015-04-12'
AND
username != ''
GROUP BY
DATE(Vrijeme),
username
。
此查询是否会返回您想要的结果:
{{1}}