【发布时间】:2020-08-27 22:58:50
【问题描述】:
我们有一个现有的 Oracle SQL 查询需要转换为 Postgres。解码对我来说很复杂,希望在转换为 Postgres CASE 方面得到一些帮助。
现有 SQL:
SELECT P.t_id p_t_id,
Q.t_id q_t_id
FROM pts Q,
pts P
WHERE P.t_id <> Q.t_id
AND ((decode(substr(P.c_num,2,1),
'0', 1,
'1', 1,
'2', 1,
'3', 1,
'4', 1,
'5', 1,
'6', 1,
'7', 1,
'8', 1,
'9', 1,
0) != 0
AND P.c_num IS NOT NULL
...rest of query...
谢谢
【问题讨论】:
标签: oracle postgresql case decode where-clause