0

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

2 Answers 2

5
select count(distinct session_id)
from tbl_track
where created_date between getdate()-1 and getdate()
Sign up to request clarification or add additional context in comments.

1 Comment

but here i will get many rows (count for each session_id), but what i need is one row with count of all unique session_id
5

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.