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
 Distinct Count of Date Day

Author  Topic 

JohnGault777
Starting Member

31 Posts

Posted - 2011-02-11 : 19:09:47
Ok I want to be able to count the number of customers that call in for a quote per day. However, in the system they can, theoretically, receive a infinite number of quotes that day. Whether a customer receives 1 or 1,000 counts in a day, I just want to count them once for that day. Each time stamp is obviously a little different due to the time. So I just need to do a count of customer numbers where they have a at least one new quote per day.

The question is how do I do a distinct count of a timestamp only focusing on the day and forgetting about the time (2:00 pm, 3:00 pm...etc).



JG777

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-11 : 19:22:11
Remove the time stamp and group by the same...
SELECT COUNT(*),DATEADD(d,0,datediff(d,0,[datefield]))
FROM [Table]
GROUP BY DATEADD(d,0,datediff(d,0,[datefield]))



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-02-12 : 03:17:49
see

http://visakhm.blogspot.com/2010/01/some-quick-tips-for-date-formating.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -