我有一个查询,它为我提供了一周内在表中进行活动的用户的不同总数。它看起来像这样。
select count(distinct(t.employeeid)) as "User Count"
from t, g
where t.eventdate between '07-SEP-13' AND '14-SEP-13'
and t.resourceid=g.id and g.resourcename = 'XYZ'`
我想知道在同一时间段内每天有活动的用户数量。所以我像这样修改了查询。
select count(distinct(t.employeeid)) as "User Count", EXTRACT(DAY from t.eventdate) as "Day"
from t, g
where t.eventdate between '07-SEP-13' AND '14-SEP-13'
and t.resourceid=g.id and g.resourcename = 'XYZ'
group by EXTRACT(DAY from t.eventdate)
order by EXTRACT(DAY from t.eventdate) ASC;`
但我的总数有所不同。第二个查询比第一个查询多给了我大约 80%。有人可以让我知道出了什么问题以及哪个查询有问题吗?提前致谢。