数据库具有关于登录和退出系统的人员的信息
我运行以下命令来查找一个人在一段时间内登录的次数。
document.forms["form_name"].getElementsByTagName("input");
这将返回
SELECT Count(Distinct(Date)) as Counter,
COUNT(*) as CNT
FROM InOutUserStatus
where date > '2019-03-11' and
Date < '2019-03-21' and
Email = 'xxxxxx.xxxxx@xxxxxxxxxx.com' group by Date
结果可能有所不同,但是我需要能够获得返回的行数的总和,在这种情况下,该行数将是3,这就是人们登录系统的天数。 一个人在一天内可能会多次登录。 我看不到要从查询中获取行数吗?
答案 0 :(得分:0)
也许将整个查询包装在子查询中并应用计数
SELECT COUNT(*)
FROM (
SELECT Count(Distinct(Date)) as Counter, COUNT(*) as CNT
FROM InOutUserStatus
WHERE date > '2019-03-11' and
Date < '2019-03-21' and
Email = 'xxxxxx.xxxxx@xxxxxxxxxx.com'
GROUP BY Date
) a
答案 1 :(得分:0)
GROUP BY
,仅聚合就足够了:
SELECT Count(Distinct [Date]) as Counter
FROM InOutUserStatus
WHERE date > '2019-03-11' AND
date < '2019-03-21' AND
Email = 'xxxxxx.xxxxx@xxxxxxxxxx.com';