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 |
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2013-03-07 : 07:26:34
|
I have a query Select bc.Category , bc.CatID , bec.EntryCatIDFrom Blog_Categories bc Inner Join Blog_Entry_Categories bec On bc.CatID = bec.CatIDWhere bc.CatID In( 6, 14 ) which is giving result set Caegory catid entrycatidFamily 6 15793Family 6 15796Family 6 15811Family 6 15831Accident 14 15813Accident 14 15965Accident 14 16130Accident 14 16376Accident 14 16378Accident 14 16380I wants the result set asCaegory catid col1 col2 col3 col4 col5 col6 Family 6 15793 15796 15811 15831 NULL NULLAccident 14 15813 15965 16130 16376 16378 16380Kamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-07 : 09:13:52
|
[code]SELECT *FROM(SELECT *,ROW_NUMBER() OVER (PARTITION BY Category,catid ORDER BY entrycatid ASC) AS SeqFROM Table)tPIVOT (MAX(entrycatid) FOR Seq IN ([1],[2],[3],[4],[5],[6]))p[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
|
|
|