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 |
|
dmaxj
Posting Yak Master
174 Posts |
Posted - 2009-01-13 : 17:19:00
|
Is there a way to compute a grand total for my results in Event_Count?My current sql statement gives me the totals per event for dates after April 1, 2008, but I can't get the grand total for the all events. Thanks.SELECT CONVERT(VARCHAR(10),eventDate,110) AS EventDate, event AS EventName, COUNT(eventDate) AS Event_Count FROM Baseline2008WHERE eventDate >= '04-01-2008' --Dates greater than April 1 2008GROUP BY EventDate, eventORDER BY eventDate ASC |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-13 : 17:23:07
|
[code]SELECT CONVERT(VARCHAR(10), eventDate, 110) AS EventDate, event AS EventName, COUNT(CASE WHEN eventDate >= '04-01-2008' THEN eventDate ELSE NULL END) AS Event_Count, COUNT(*)FROM Baseline2008GROUP BY EventDate, eventORDER BY eventDate ASC[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-13 : 23:58:03
|
quote: Originally posted by dmaxj Is there a way to compute a grand total for my results in Event_Count?My current sql statement gives me the totals per event for dates after April 1, 2008, but I can't get the grand total for the all events. Thanks.SELECT CONVERT(VARCHAR(10),eventDate,110) AS EventDate, event AS EventName, COUNT(eventDate) AS Event_Count FROM Baseline2008WHERE eventDate >= '04-01-2008' --Dates greater than April 1 2008GROUP BY EventDate, event[code]WITH ROLLUP[/blue]ORDER BY eventDate ASC
use with rollup as above |
 |
|
|
|
|
|
|
|