PostgreSQL被除数为0的处理方法
方法一:使用case语法
select case when id=0 then 0 else id/2 end from c2;
方法二:自定义操作符
CREATE OR REPLACE FUNCTION DIV_ZERO(NUMERIC,NUMERIC)
RETURNS NUMERIC AS $BODY$
SELECT CASE WHEN $2 = 0 THEN 0 ELSE $1/$2 END;
$BODY$
LANGUAGE SQL;
标签:BODY,PostgreSQL,处理,方法,NUMERIC,被除数,id
From: https://www.cnblogs.com/javaxubo/p/17498150.html