Sometimes my queries have long case when statements. For example,
CASE WHEN BASE_YM = TO_CHAR(DEFAULT_YM, 'YYYYMM') THEN '00'
WHEN BASE_YM = TO_CHAR(DEFAULT_YM - 1 MONTHS, 'YYYYMM') THEN '01'
WHEN BASE_YM = TO_CHAR(DEFAULT_YM - 2 MONTHS, 'YYYYMM') THEN '02'
.
.
.
WHEN BASE_YM = TO_CHAR(DEFAULT_YM - 35 MONTHS, 'YYYYMM') THEN '35'
WHEN BASE_YM = TO_CHAR(DEFAULT_YM - 36 MONTHS, 'YYYYMM') THEN '36'
This case when statement itself takes up 37lines and I was wondering if there might be maybe a way to shorten the case when statement by using i=00, ..., 36 something like that?