且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Oracle查询中有条件地选择列

更新时间:2022-06-15 21:45:57

您需要个案说明:

select (case when lookup = 8 then 8 else lookup end) as lookup

如果lookup是字符串,则可能需要:

If lookup is a character string, you probably want:

select (case when lookup = '08' then '08' else lookup end) as lookup

如果lookup是整数,并且您想将其转换为字符串,则:

If lookup is an integer and you want to convert it to a string, then:

select (case when lookup = 8 then to_char(lookup, '00') else to_char(lookup, '00') end) as lookup

但是,这对我来说似乎是多余的.

However, that would seem redundant to me.