4、oracle迁移到postgres-oracle中使用的`decode`函数使用`case when`统一语法

oracle迁移到postgres-oracle中使用的decode函数使用case when统一语法

oracle中也有使用case when语法,使用decode函数比较简洁。

1、oracle的decode语法

匹配stu_type1的值的班级为优秀班级

select 
decode(stu_type,'1','优秀班级','非优秀班级') 
from sys_stu;

2、postgres的case when

select 
(case when stu_type == '1' then '优秀班级' else '非优秀班级' end )
from sys_stu;
posted @ 2023-08-23 11:23  站着说话不腰疼  阅读(258)  评论(0)    收藏  举报