请问oracle中如何根据条件查询出不同的字段? 比如说如果查询出status为1,那么我就查询字

2025-03-23 19:57:00
推荐回答(2个)
回答1:

select case when status = '1' then 字段一 when status = '2' then 字段二 end 字段_case,
decode(status, '1', 字段一, '2', 字段二) 字段_decode
from 表

case when适合多条件,格式好看点,decode适合少条件,简洁。

回答2:

case when