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 2005 Forums
 Transact-SQL (2005)
 SubGroup Totals

Author  Topic 

hrishy
Starting Member

47 Posts

Posted - 2008-09-12 : 01:37:10
Hi

I have a dataset like this


Name AssetClass Status
ABC Mortgage Good
ABC Insurance Bad
GXZ Travel Good
............


I need to write a query that provides subtotals for the status feild is it possible in a single sql any ideas on how to achieve this

result needs to be

Name AssetClass Status
ABC Mortgage Good
GXZ Travel Good
-----------------------------------------
2
ABC Insurance Bad
----------------------------------------
1..............

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-12 : 02:53:22
quote:
Originally posted by hrishy

Hi

I have a dataset like this


Name AssetClass Status
ABC Mortgage Good
ABC Insurance Bad
GXZ Travel Good
............


I need to write a query that provides subtotals for the status feild is it possible in a single sql any ideas on how to achieve this

result needs to be

Name AssetClass Status
ABC Mortgage Good
GXZ Travel Good
-----------------------------------------
2
ABC Insurance Bad
----------------------------------------
1..............




Where do you want to show the data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hrishy
Starting Member

47 Posts

Posted - 2008-09-12 : 08:20:52
Hi

I want to display the data in sqlserver management studio output or in CSV format

regards
Hrishy
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-12 : 08:24:02
quote:
Originally posted by hrishy

Hi

I want to display the data in sqlserver management studio output or in CSV format

regards
Hrishy


Read about ROLLUP operator in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -