Oracle基础知识:DECODE、NVL
select 1 from PMADW.GET_WX_DATAPUSH_NEW_CHECK A INNER JOIN PMADW.V_EXCEPTION_QTY_MAIN B on DECODE( A.VALUE_NAME,B.V_QTY_CODE,1,B.PARENTID,1,0) = 1 and A.DAY_ID = B.DAY_ID AND B.N_GRANULARITY = 1 where A.DAY_ID = TO_DATE('{$yest}','yyyy-mm-dd') and A.IS_NEW = 0 AND EXISTS( SELECT value_name FROM PMADW.GET_WX_DATAPUSH_NEW_CHECK t2 WHERE t2.DAY_ID = b.DAY_ID AND t2.value_name = nvl(b.parentid,b.V_QTY_CODE)) AND ROWNUM <=1 DECODE(a,b,1,c,2,0) 解释: switch(a){ case b: return 1; break; case c: return 2; break; default: return 0; } nvl(a,b) 解释: return (a != '') ? a : b;