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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-12-14 : 10:53:51
|
Cam writes "I have a table that looks something like this:date email----- ----aaa 1-Janbbb 5-Janaaa 3-Febccc 6-Feb What I'm trying to do is count the number of new, unique emails that occured in each month. In my example - I'm looking to see that there were 2 in Jan and 1 in Feb (since the Feb 3 'aaa' had already been counted).Can anyone help me wrap my noodle around this? Thanks in advance,Cam" |
|
|
efelito
Constraint Violating Yak Guru
478 Posts |
Posted - 2001-12-14 : 11:35:44
|
| Something like this should do the trickselect cast(datepart(month, t1.date) as char(2)) + '/' + cast(datepart(year, t1.date) as char(4)), count(t1.email)from (select min(date) as date, emailfrom tablenamegroup by email) as t1group by cast(datepart(month, t1.date) as char(2)) + '/' + cast(datepart(year, t1.date) as char(4))Jeff BanschbachConsultant, MCDBA |
 |
|
|
|
|
|