回首忆惘然
1, deocde 与 case when 的作用相同,用于不同条件分支的不同处理。于case when 相比只是用法不同。同样可以嵌套和满足多个值。2,多个值decode(name, 'Wang', '001', 'Li', '002', '003')相当于casewhen name = 'Wang'then '001'when name = 'Li'then '002'else '003'end3, 嵌套decode(name, 'Wang', decode(sno, '001', 'Yes', ''), 'Li', decode(sno,'002','Yes',''), decode(sno, '003','Yes',''))相当于casewhen name = 'Wang'then casewhen sno='001'then 'Yes'else ''endwhen name='Li'then casewhen sno='002'then 'Yes'else ''endelse casewhen sno='003'then 'Yes'else ''endend