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 |
|
PatDeV
Posting Yak Master
197 Posts |
Posted - 2006-06-14 : 13:40:00
|
| How can i get result from each month seperatly.if i put @date = '01/01/2006'i would like to getdate for date before that and seperately by month. how can i put this in loop for that to return each month data please help!!declare @date varchat(50)SELECT DISTINCT s.testkey,c.testID, ic.FirstName, ic.LastName, ic.Company, c.Status,count(s.testCnt) cntFROM test1 s left join test2 c on c.testKey = s.testKeyINNER JOIN test3 ic ON c.testContactKey = ic.testContactKeyWHERE (testlag = 1) and (StartDate <= @date)AND (EndDate IS NULL OR EndDate > @date) AND (Status NOT IN ('R', 'U', 'S'))group by s.testkey,c.testID, ic.FirstName,ic.LastName, ic.Company, c.Status |
|
|
PatDeV
Posting Yak Master
197 Posts |
Posted - 2006-06-14 : 13:40:44
|
| Also need to show colunm for each month from Jan to Dec.Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-06-14 : 15:05:15
|
quote: Originally posted by PatDeV Also need to show colunm for each month from Jan to Dec.Thanks
Group by month for which field? StartDate? EndDate?Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|