Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Everyone.

I don't have any experience in writing queries. Please help me to sort out this.

i've a table like
col1   col2    col3 
----------------------  
1       25     comp
1       27     elec
2       20     comp
3       13     elec
3       17     comp
3       23     comp
4       27     elec

i want to get output like this
col1   comp   elec
-------------------------
1      25     27
2      20      null
3      13     40(13+27)
4      null   elec

Thanks in Advance.
Anil
Posted
Updated 30-Aug-13 3:28am
v2
Comments
[no name] 30-Aug-13 9:31am    
http://shaikhnizam.blogspot.com/2009/02/how-to-write-pivot-query-in-sql-server.html
laddunoorianilyadav 30-Aug-13 9:59am    
Solved using with pivot option.

1 solution

Using pivot option to resolved
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900