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 |
sur200
Starting Member
7 Posts |
Posted - 2013-03-04 : 05:02:59
|
create table temp(id integer, comments varchar(20), custom_id integer);insert into temp values(1,'CEO comments', 98)insert into temp values(2,'SEO comments', 99)insert into temp values(3,'X comments', 100)insert into temp values(1,'SEO comments', 99)want output likeid CEO_Comments SEO_Comments _ExtraComments1 Ceo comments seo comments Null2 null seo comments null3. null null x commentsany idea?Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 05:20:24
|
[code]SELECT id,MAX(CASE WHEN comments = 'CEO comments' THEN comments END) AS CEO_comments,MAX(CASE WHEN comments = 'SEO comments' THEN comments END) AS SEO_comments,MAX(CASE WHEN comments = 'X comments' THEN comments END) AS Extra_commentsFROM table GROUP BY id[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|