Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to combine group of data in One Expand / Collapse
Author
Message
Posted Friday, December 18, 2009 12:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 5, 2013 9:30 AM
Points: 1, Visits: 6
Hi,

Following is the script for table creation. Data for the table is attached already in Excel file named Data.xls

CREATE TABLE [dbo].[Account] (
[ServiceCode] [varchar] (100) NOT NULL ,
[ServiceName] [varchar] (100) NOT NULL ,
[AccountNo] [nvarchar] (30) NOT NULL ,
[POCode] [numeric](18, 0) NOT NULL ,
[POType] [numeric](18, 0) NOT NULL ,
) ON [PRIMARY]


Following query will display data
SELECT servicename, count(accountNo) As [Total Accounts],
case POtype When 1 then 'HO' else 'SO'
end as category
FROM Account WHERE ServiceCode='140101'
group by servicename,POType


Like this:
Servicename Total Accounts Category
Savings Account 349 HO
Savings Account 296 SO

I need information in the following format

Servicename HO SO
Savings Account 349 296

Is it possible with simple SQL or stored procedure is required? If it is possible using standard SQL, then that will be preferred.

Thanks


  Post Attachments 
Data.XLS (7 views, 117.00 KB)
Post #836149
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse