I would like to know how to reference the values from a column in my query for use in a adjacent column having a different column name. As you can see, I just don't see that it is necessary to place the case statement shown below twice in my code.
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",
I would like the section below to just insert the values from the case section above.
phone, value from Next Repricing Date AS "balloon date"
from my.table
case pterm||' '||ptermc when '0' then date(digits(matdt7)) when '1 D' then curdate() when '1 M' then …? That would let you avoid repeating the same expression multiple times, which would make your query simpler-looking and potentially more readable.