9.18. 條件表示式
Was this helpful?
Was this helpful?
CASE expression
WHEN value THEN result
[WHEN ...]
[ELSE result]
ENDSELECT a,
CASE a WHEN 1 THEN 'one'
WHEN 2 THEN 'two'
ELSE 'other'
END
FROM test;
a | case
---+-------
1 | one
2 | two
3 | otherSELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END;COALESCE(value [, ...])SELECT COALESCE(description, short_description, '(none)') ...NULLIF(value1, value2)SELECT NULLIF(value, '(none)') ...GREATEST(value [, ...])LEAST(value [, ...])