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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Suppress duplicates ; totals & subtotals

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-23 : 08:18:59
Cassie writes "Can you please help with this Query.

I have written a stored procedure that aggregates data and creates a temp table in the following format.

Singer Song #Songs sold
------ ---- -----------
Singer1 Song1 20
Singer1 Song2 10
Singer1 Song3 5
Singer2 Song1 3
Singer3 Song1 15
Singer3 Song2 12

Now I need to add to the Stored procedure to output the
data in the following format, ORDERED BY top selling Singer

1. Singer1
Song1 20
Song2 10
Song3 5
Total Singer 1 35

2. Singer 3
Song1 15
Song2 12
Total Singer 3 27

3. Singer 2
Song1 3
Total Singer 2 3

How do I do this? Thanks for your help."

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-02-23 : 09:06:32
>>How do I do this? Thanks for your help."

By using a report writer, such as reporting services, crystal reports, Access. It depends on what method you want to use to present this data. Formatting output & creating groups for reports is not something that you do in T-SQL.

- Jeff
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-02-23 : 14:36:37
Have a look at the ROLLUP operator,
It can be used to deliver totals to the client, the client has to format them of course.

rockmoose
Go to Top of Page
   

- Advertisement -