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 |
|
redhooked
Starting Member
2 Posts |
Posted - 2008-04-15 : 11:54:58
|
| this is a seemingly simple query, but i've been googling around for a while and haven't been able to come up anything, probably because i simply can't explain what I'm trying to docan someone please point me in the right direction? using sql server 2005.tbl_vendorprice looks like:id vend price1 A 2.001 B 3.002 A 4.002 B 3.503 A 8.003 B 8.50and this is what i want as a resultid vendA VendB1 2.00 3.002 4.00 3.503 8.00 8.50thanksDavid |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-15 : 12:02:18
|
| [code]SELECT id,SUM(CASE WHEN vend='A' THEN price ELSE 0 END) AS vendA,SUM(CASE WHEN vend='B' THEN price ELSE 0 END) AS vendBFROM YourTableGROUP BY id[/code] |
 |
|
|
redhooked
Starting Member
2 Posts |
Posted - 2008-04-15 : 12:43:29
|
| perfect. thank you |
 |
|
|
|
|
|