以下是我们所拥有的:
登录表:(user_id, time_of_login)
以下是我们要查询的内容:
仅登录的用户数:
登录多于一日的用户数:
示例: user1下午4:29 user2 4:29 PM user3 4:29 PM user1下午4:29 user2 4:29 PM user5下午4:29 user6 4:29 PM
我们希望这有帮助
答案 0 :(得分:0)
登录一次:
SELECT user_id, COUNT(*) AS nr_of_logins
FROM table
GROUP BY user_id
HAVING nr_of_logins = 1
多次登录:
SELECT user_id, COUNT(*) AS nr_of_logins
FROM table
GROUP BY user_id
HAVING nr_of_logins > 1
注意:我没有测试过这个。
答案 1 :(得分:0)
select user_id, count(*)
from table
group by user_id
having count(*)=1
和下一个:
select user_id, count(*)
from table
group by user_id
having count(*)>1