oracle迁移到postgres-oracle中使用的decode
函数使用case when
统一语法
oracle中也有使用case when
语法,使用decode
函数比较简洁。
1、oracle的decode
语法
匹配stu_type
为1
的值的班级为优秀班级
select
decode(stu_type,'1','优秀班级','非优秀班级')
from sys_stu;
2、postgres的case when
select
(case when stu_type == '1' then '优秀班级' else '非优秀班级' end )
from sys_stu;