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
 General SQL Server Forums
 New to SQL Server Programming
 How to split one column Output into two Columns

Author  Topic 

khanewal
Starting Member

33 Posts

Posted - 2010-09-06 : 22:24:47
HI Friends,

I have this data

DocID object
1 A
1 A
2 H
3 A
1 H

Required output

DocID ObjectA ObjectH Total
1 3 1 4
2 0 1 1
3 1 0 1

Total 4 2 6

can you please tell me how I can produce this kind of output in SQL

Sachin.Nand

2937 Posts

Posted - 2010-09-07 : 00:37:48
You can use the PIVOT operator.


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

khanewal
Starting Member

33 Posts

Posted - 2010-09-07 : 01:40:20
Thanks its done, and also can you please let me know if I can create new run time column to add total of object A and object B

Go to Top of Page
   

- Advertisement -