I have a table like following
I want to summeraize it in to following table
How to do it using at least sql?
Edit class3 count should be 2. That's a typo
This can be done in SQL as below
SELECT Org, SUM(CASE WHEN class='class1' THEN 1 ELSE O END) As Class1Count,
SUM(CASE WHEN class='class2' THEN 1 ELSE O END) As Class2Count,
SUM(CASE WHEN class='class3' THEN 1 ELSE O END) As Class3Count,
SUM(CASE WHEN class='class4' THEN 1 ELSE O END) As Class4Count
FROM tableName
GROUP By Org
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With