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 |
|
abenitez77
Yak Posting Veteran
53 Posts |
Posted - 2012-01-30 : 12:43:20
|
| How can i get my table to show the results i want below? Pivot table? I've never used pivot before.Table:tocid prop_id str_val num_val1059786 104 USD NULL1059786 105 Pricing Null1059786 108 NULL 1539.17results:tocid str_val str_val num_val1059786 USD Pricing 1539.17 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-30 : 12:46:24
|
you need to GROUP BY tocidSELECT tocid,MAX(CASE WHEN prop_id = 104 THEN str_val END) AS str_val1,MAX(CASE WHEN prop_id = 105 THEN str_val END) AS str_val2,MAX(CASE WHEN prop_id = 108 THEN num_val END) AS num_valFROM tableGROUP BY tocid ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|