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.
| Author |
Topic |
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2010-02-11 : 09:52:05
|
| Hi I am using SQl 2005 standard and the table (tblA) as below.ORDUNIQ -----OPTFIELD-------VALUE 111 ------ COMM -------Null 111 ------DESP ------- 20091221 111 ------MANI ------- 1 354 ------ COMM ------- 354 ------DESP ------- 20090614 354 ------MANI ------- 4Expected Result isORDUNIQ ----Comm ------Desp--------MANI111-------- Null ----20091221------ 1354------- ----20090614------ 4Plesae help |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-11 : 09:56:44
|
| [code]SELECT ORDUNIQ,MAX(CASE WHEN OPTFIELD='COMM' THEN VALUE ELSE NULL END) AS COMM,MAX(CASE WHEN OPTFIELD='DESP' THEN VALUE ELSE NULL END) AS DESP,MAX(CASE WHEN OPTFIELD='MANI' THEN VALUE ELSE NULL END) AS MANIFROM tblAGROUP BY ORDUNIQ[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2010-02-11 : 10:10:32
|
HiIts perfect . THANKS a LOTquote: Originally posted by visakh16
SELECT ORDUNIQ,MAX(CASE WHEN OPTFIELD='COMM' THEN VALUE ELSE NULL END) AS COMM,MAX(CASE WHEN OPTFIELD='DESP' THEN VALUE ELSE NULL END) AS DESP,MAX(CASE WHEN OPTFIELD='MANI' THEN VALUE ELSE NULL END) AS MANIFROM tblAGROUP BY ORDUNIQ ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-11 : 10:13:17
|
Welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|