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 |
|
bjcc77
Starting Member
5 Posts |
Posted - 2006-02-02 : 08:11:11
|
| I have the following a table called stockCode Description PriceGroup Price560002 Panel 1 193.31560002 Panel 2 241.63560002 Panel, 3 277.88560002 Panel, 4 400.86560003 Panel 1 184.34560003 Panel 2 235.64560003 Panel, 3 267.99560003 Panel, 4 412.77and i am needing to insert this data into a new table .This is how I would like the data to appear in the a new table called Stock1Code Description PG1 PG2 PG3 PG4560002 Panel 193.31 241.63 277.88 400.86560003 Panel 184.34 235.64 267.99 412.77 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-02 : 08:34:21
|
| [code]select code, description, sum(case when price_group = 1 then price else 0 end) as pg_1, sum(case when price_group = 2 then price else 0 end) as pg_2, sum(case when price_group = 3 then price else 0 end) as pg_3, sum(case when price_group = 4 then price else 0 end) as pg_4from stockgroup by code, description[/code]----------------------------------'KH' |
 |
|
|
bjcc77
Starting Member
5 Posts |
Posted - 2006-02-02 : 08:38:15
|
| Thank you |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|