1

我已经实现了以下查询以将 col_nm 从行旋转到列:

    select  grp_id,orig_businesseffectivedate,
max(case when col_nm= 'bus_seg_cd' then col_val end)  as bus_seg_cd,
max(case when col_nm= 'dft_insur_cd' then col_val end)  as dft_insur_cd,
max(case when col_nm= 'drc_indrct_ind' then col_val end) as drc_indrct_ind,
max(case when col_nm= 'ifrs9_stream' then col_val end) as ifrs9_stream,
max(case when col_nm= 'stff_loan_cd' then col_val end) as stff_loan_cd,
max(case when col_nm= 'loan_prps_cd' then col_val end)  as loan_prps_cd,
max(case when col_nm= 'org_bu' then col_val end)  as org_bu,
max(case when col_nm= 'prime_ind' then col_val end) as prime_ind,
max(case when col_nm= 'rcrr_prd_cd' then col_val end) as rcrr_prd_cd,
max(case when col_nm= 'scrty_ind' then col_val end) as scrty_ind,
max(case when col_nm= 'stff_loan_cd' then col_val end) as stff_loan_cd
from crz_shrd.cpp_rcrr_prd_mappng_grp_dtl
group by grp_id,orig_businesseffectivedate

以下是看起来正确的输出: 查询结果

我想知道 col_nm 是否获得了新值,有没有办法动态处理它或使旋转通用?

4

0 回答 0