Replace a NULL with specific value

From SQLZOO
Revision as of 14:53, 17 July 2012 by Connor (Talk | contribs) (Created page with "Replace a NULL with a specific value <div class='ht'> <div class=params>schema:gisq</div> <div> The SQL standard is COALESCE </div> <source lang=sql class='tidy'...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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