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 |
|
ik6s
Starting Member
1 Post |
Posted - 2011-05-03 : 09:55:06
|
| I have a table and have the columns ZipCode, SalesPerson, SalesType.I would like to write a select statement which would give me a table with columns:Zipcode, SalesPerson, SalesType1 count per salesperson and per zipcode, SalesType2 count per salesperson and per zipcode.I have no clue how to do this. Please help and thanks a lot.zipcode salesperson salestypecount(phone) salestypecount(floor)12345 A 5 10 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-03 : 10:09:50
|
| select zipcode, salesperson, SUM(case when SalesType = 'phone' then 1 else 0 end), SUM(case when SalesType = 'floor' then 1 else 0 end)group by zipcode, salesperson==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|