我有跟踪表tbl_track,其中包含id,session_id,created_date字段
我需要计算一天的唯一session_id
这是我得到的:
select count(0)
from (
select distinct session_id
from tbl_track
where created_date between getdate()-1 and getdate()
group by session_id
)tbl
我觉得它可能是更好的解决方案
答案 0 :(得分:5)
select count(distinct session_id)
from tbl_track
where created_date between getdate()-1 and getdate()
答案 1 :(得分:5)
为什么不完全按照你的要求去做?
select count(distinct session_id)
from tbl_track
where created_date between getdate()-1 and getdate()