我正在使用oracle 10g,我有一个登录用户的表
created userid
-------------------- ------
10-jul-2014 10:10:10 usr1
10-jul-2014 10:12:10 usr2
10-jul-2014 11:12:10 usr1
10-jul-2014 12:12:10 usr3
13-jul-2014 10:12:10 usr1
13-jul-2014 11:12:10 usr2
我正在寻找的输出是
created count(userid)
----------- ------------------
10-jul-2014 3 (3 unique users)
13-jul-2014 2 (2 unique users)
我提出的查询未按预期工作
select trunc(created) cr, userid
from loggedinusers
group by trunc(created), userid
order by trunc(created) asc;
答案 0 :(得分:2)
使用以下查询
select trunc(created) cr, count(distinct userid)
from loggedinusers
group by trunc(created)
order by trunc(created) asc;
答案 1 :(得分:0)
select trunc(created) cr, count(userid) as cnt
from loggedinusers
group by trunc(created)
order by trunc(created) asc;