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 |
TomHand
Starting Member
8 Posts |
Posted - 2012-11-15 : 01:07:07
|
I got this table with 4 columns:Col1 Col2 Col3 Col4T A a1 6T B a1 7T A b1 5T B b1 8How to make a query so that when user search for 'T', the query will show the result like this:T a1 b1A 6 5B 7 8 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-15 : 05:27:55
|
[code]SELECT Col2 AS [T],[a1],[b1]FROM (SELECT Col2,Col3,Col4 FROM Table WHERE Col1 = @YourValue )tPIVOT (MAX(Col4) FOR Col3 IN ([a1],[b1]))p[code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|