Company_ID Customer_ID Status 1 3453453 S 1 3488453 E 1 3453453 G 2 4453453 S 3 3489453 S 2 1345453 E 3 3487453 S 3 3453453 S 3 3454553 S
Company_ID G S E 1 1 1 1 2 0 1 1 3 0 4 0
SELECT Company_ID, [G], [S], [E] FROM ( SELECT Company_ID, Customer_ID, [Status] FROM YourTable ) DT PIVOT(COUNT(Customer_ID) FOR [Status] IN ([G], [S], [E])) PT
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)