Reputation: 20824
I have tracking table tbl_track with id, session_id, created_date fields
I need count unique session_id for one day
here what i got:
select count(0)
from (
select distinct session_id
from tbl_track
where created_date between getdate()-1 and getdate()
group by session_id
)tbl
im feeling that it could be better solution for it
Upvotes: 0
Views: 128
Reputation: 11987
select count(distinct session_id)
from tbl_track
where created_date between getdate()-1 and getdate()
Upvotes: 5
Reputation: 86698
Why not just do exactly what you ask for?
select count(distinct session_id)
from tbl_track
where created_date between getdate()-1 and getdate()
Upvotes: 5