database - Categorize using spark sql -


i have table following enter image description here

i want summeraize in following table

enter image description here

how using @ least sql?

edit class3 count should 2. that's typo

this can done in sql below

select org, sum(case when class='class1' 1 else o end) class1count,        sum(case when class='class2' 1 else o end) class2count,        sum(case when class='class3' 1 else o end) class3count,        sum(case when class='class4' 1 else o end) class4count tablename group org 

Comments

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -