DECODE和CASE WHEN异曲同工之妙
joke7164
共 843字,需浏览 2分钟
·
2024-03-23 21:30
案例:DECODE和CASE WHEN,IF THEN ELSEIF THEN END IF可达到相同的效果。
原始数据
SELECT MO,TP_PHASE,MO_STAT,PL_ID,PROD_ID,MO_OMTRL_TYPE,P_QTY,PB_DATE FROM TB_PP_MO
DECODE修改TP_PHASE显示正常数据
SELECT MO,decode(TP_PHASE,0,'SMT',1,'AI',2,'Coating',4,'组装',5,'DIP',7,'注塑')TP_PHASE ,MO_STAT,PL_ID,PROD_ID,MO_OMTRL_TYPE,P_QTY,PB_DATE FROM TB_PP_MO
CASE WHEN 修改TP_PHASE显示正常数据
SELECT MO,(CASE TP_PHASE WHEN 0 THEN 'SMT' WHEN 1 THEN 'AI' WHEN 2 THEN 'Coating'WHEN 4 THEN '组装'WHEN 5 THEN 'DIP' ELSE'注塑'END) A1,MO_STAT,PL_ID,PROD_ID,MO_OMTRL_TYPE,P_QTY,PB_DATE FROM TB_PP_MO
评论