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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 total number of customers

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-04-29 : 09:16:23
hi,
I have a person table with a field createdate and personid,

how can I display how many customers existed in the table by date.

eg.
1/4 200
2/4 250
3/4 256
4/4 280


regards,
amie

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-29 : 09:20:37
If CreateDate is either SMALLDATETIME or DATETIME, try this

SELECT DATEADD(DAY, DATEDIFF(DAY, '19000101', CreateDate), '19000101'),
COUNT(DISTINCT PersonID)
FROM Table1
GROUP BY DATEADD(DAY, DATEDIFF(DAY, '19000101', CreateDate), '19000101')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-04-29 : 09:24:30
hi Peso,
no that doesn't work,
I this shows me customers that were created on each day.

I would need to accumulate the values each day...
?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-29 : 09:33:51
Why didn't you tell us from the beginning?

Mail m_k_s and he will help you soon.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-04-29 : 10:23:04
apologies for not being clear peso, will email now.
Go to Top of Page
   

- Advertisement -