... COUNT( CASE WHEN status = 1 THEN status END ) AS Status1Count, COUNT( CASE WHEN status = 2 THEN status END ) AS Status2Count, ...... and it seemed to work properly. Thanks for the help. Have you ever thought about going into teaching?
> ... > SUM( CASE WHEN status = 1 THEN Sales ELSE 0 END ) AS Sales1, > SUM( CASE WHEN status = 2 THEN Sales ELSE 0 END ) AS Sales2, > ... >>>Can I do a conditional COUNT in a query? For example, I have Suppliers that have Customers that have Transactions. For each Supplier I am summing the Amount of each Transaction to show total sales for a Supplier. Pretty basic stuff, and am getting a result set like so:
>>Supplier Sales >>-------- ----- >>1 1000.00 >>2 750.00 >>3 12000.00 >>4 100.00 >>5 5.00 >>>>