我想知道如何在查询中引用列中的值,以便在具有不同列名的相邻列中使用。如您所见,我只是看不到有必要在我的代码中放置两次如下所示的 case 语句。
select acct, name, address,
case when pterm||' '||ptermc = '0' then date(digits(matdt7))
when pterm||' '||ptermc = '1 D' then curdate()
when pterm||' '||ptermc = '1 M' then date(digits(prevd7))+30 day
when pterm||' '||ptermc = '3 M' then date(digits(prevd7))+90 day
when pterm||' '||ptermc = '6 M' then date(digits(prevd7))+180 day
when pterm||' '||ptermc = '12 M' then date(digits(prevd7))+365 day
else null end as "Next Repricing Date",
我希望下面的部分只插入上面案例部分的值。
phone, value from Next Repricing Date AS "balloon date"
from my.table