Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using Count to find # of Distinct entries

Author  Topic 

rico16135
Starting Member

11 Posts

Posted - 2008-04-17 : 23:18:56
I need a query to return the number of distinct call_num(s) between two timestamps.

For example search between 2008-04-17 05:00:00.000 and
2008-04-19 05:00:00.000

Calls
----------
id_tag(unique id) | status | call_num | entry_id(timestamp)

1 HOLD 0123456789 2008-04-17 05:07:00.080
2 ONSCENE 012345679 2008-04-17 05:10:00.012
3 ENROUTE 321654987 2008-04-19 04:00:00.000

so the sample answer would be : 2

rico16135
Starting Member

11 Posts

Posted - 2008-04-17 : 23:21:21
sry I inserted two calls with similar call_num in the example, picture a 4th entry with a different call_num between the two times.
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-04-18 : 00:06:27
Select count(distinct call_num) from tablename where entry_id between STARTDATE(2008-04-17 05:00:00.000) and ENDDATE(2008-04-19 05:00:00.000
)

Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page
   

- Advertisement -