This is my SQL:
SELECT DISTINCT(CASE WHEN state=18 THEN lga ELSE 'Others' END) LGA,
COUNT(CASE WHEN choice=21 THEN choice END ) NDCH
FROM bio
GROUP BY lga
My expectation is for it to give me all LGA with state=18, and if the state is not equal to 18 let them be grouped as ‘Others’, but I usually have more than one ‘Others’.
Please help.
Consider a
group byon the case statement: