📜  除以零 postgres - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:23.297000             🧑  作者: Mango

代码示例2
-- avoid division error in Postgres
value/NULLIF(col, 0)  -- if col == 0, NULL will be returned
value/COALESCE(NULLIF(col, 0), 1)  -- if col == 0, value will be returned