Home > Enterprise >  Sql case in case
Sql case in case

Time:04-09

i have this select:

current_date - min(case when psi.status = 'OPEN' and psi.due_date < current_date then psi.due_date end) as has_overdue_days

Return has_overdue_days its okay, but other rows are blanks in result, how to make case in case that if return blank shows '0'

CodePudding user response:

you can use coalesce(<expr/your sql>, 0). It chooses the first non-null value from the expression list, have a 0 at the end will return 0 when blank

  • Related