I need to show the most frequent value between two groups on a selection, and it has to go along a message, so bear with me. I’m using Oracle XE and this is what I’ve got so far:
SELECT (
CASE type
WHEN 0 THEN 'heroes'
WHEN 1 THEN 'villains'
ELSE 'neither'
END
) AS MostFrequent
FROM (
SELECT type
FROM mutants
GROUP BY type
ORDER BY count(*) DESC
) WHERE rownum <= 1
So far if there are more Mutants with type 0 than type 1 it shows Heroes and then when there are more of type 1 than type 0, it shows villains, but when they’re tied, it shows no data, and that doesn’t work for me 🙁 I need it to say ‘neither’, so any help will be widely appreciated.
1 Answer