select decode(type_id, null, 'Unknown', type_id), name, count(*) from ( select 'asdf' type_id, 'name1' name from dual union all select 'asdf' type_id, 'name2' name from dual union all select null type_id, 'name3' name from dual ) test_table group by type_id,name;
I agree with @sql_mommy that CASE
will probably look better. But I do not agree that you are using TechOnTheNet as your primary source of information. You are usually better off with official documentation, and the DECODE page is a good example of why.
DECODE
has some weird behavior: "In the DECODE function, Oracle considers two zeros equal." This behavior is not mentioned in the TechOnTheNet article.
source share