sql server - Show Sale Data By Salesman By Region -


i need sql server query show grid of sales region sales person this:

region   mitchell   mark    manny     moe ----------------------------------------- west        0        0        0        0 north       0        1        1        1 east        1        0        0        0 south       0        0        0        0 

how can have sql query output data this? know use return data not in correct breakdown or format.

select region, salesperson, count(sales) salesdatabase group region, salesperson 

you can pivot table. try this:

;with data (     select region, salesperson, sales     salesdatabase ) select region       ,[mitchell]       ,[mark]       ,[manny]       ,[moe] data d pivot (count(sales) salesperson in ([mitchell], [mark], [manny], [moe])) p; 

you can find more information here.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -