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 |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-11-22 : 09:02:44
|
| A stored procedure lists time spent reading a page.SELECT ModuleSequence, ModuleTitle, Minutes FROM CourseVisitations WHERE UserID = @UserID ORDER BY CourseID, ModuleSequenceI'd like to return a last row with a total minutes, ModuleTitle set to 'total' and modulesequence NULL.It looks like I'll need to repeat the query in a Union All. Union ALLSELECT NULL, 'Total Minutes', Sum(Minutes) FROM (SELECT Minutes from Coursevisitations where userid=@Userid) AIs there a simpler way to get the total ?Sam |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-11-22 : 14:10:36
|
| Rob,I've played (a little) with Rollup.Rollup wants to total all the columns, some of which are text.Isn't this a problem?Sam |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2002-11-22 : 14:55:15
|
| I think you need to add GROUP BY's and aggregate formulas to use ROLLUP. Don't remember. But i think that's how it knows what to roll-up, and using which formula.- Jeff |
 |
|
|
Scott
Posting Yak Master
145 Posts |
Posted - 2002-11-25 : 04:10:50
|
| Just pop a:compute sum(minutes) as [Total Minutes]under your select. NOTE: ADO will now bring through 2 recordsets one with the select and one with the total. |
 |
|
|
|
|
|