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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-12-16 : 14:09:51
|
| i have a table that has number of messages entered each day per affiliate.so table ismessagesfields - date,affiliatecodeHow can I query by affiliatecode,startdate and end date and get a list per week of the number of messages grouped by date? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-16 : 14:15:42
|
| [code]SELECT affiliatecode,DATEADD(dd,DATEDIFF(dd,0,date),0) AS date,COUNT(*)FROM messagesWHERE date BETWEEN @startdate AND dateadd(dd,1,@enddate)GROUP BY affiliatecode,DATEADD(dd,DATEDIFF(dd,0,date),0)[/code] |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-12-16 : 14:29:56
|
| but I want it to show a list per week (not day)?where does this show per week |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-12-17 : 05:54:52
|
| I modified this to weeks but is there anyway for it to show all weeks even 1 with 0 entries and just show a 0? |
 |
|
|
|
|
|
|
|