Hi Stackoverflow super stars…
Here’s my problem. I have a stored procedure that outputs a pretty straightforward table of grouped and summed values. Typical stuff… company name, number of clients at a company, business rep for the company, annual revenue for the company, etc.
That works fine.
What I need now, is the summary row. Last row of the output should be the sum of number of clients, annual revenue, etc. Kind of the same thing you would do by hitting the autosum button in excel. (Which btw is exactly what we do now.)
My inital guess is to insert all the data into a temp table within the stored procedure and then insert the summary values at the very end prior to spitting out the data.
Thoughts? Is this way too confusing?
Thanks,
Your temp table suggestion sounds pretty good.
You could have the Stored Procedure return two separate result sets, but that generally becomes a hassle when you need to read the data via ADO.NET or whatever.
But your own suggestion of the temp table is the one that I would go with.