Replace a NULL with specific value

From SQLZoo

Replace a NULL with a specific value

schema:gisq

The SQL standard is COALESCE

SELECT code, name,
    IIF(ISNULL(leader),
        'NO LEADER RECORDED!',
        leader)
  FROM party
SELECT code, name,
    COALESCE(leader, 'NO LEADER RECORDED!')
  FROM gisq.party
SELECT code, name,
    COALESCE(leader, 'NO LEADER RECORDED!')
  FROM party
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: digitalocean-sqlzoo