没有从案例陈述中检索确切的结果

时间:2014-07-02 17:48:45

标签: mysql sql oracle

我使用的是以下查询,但是Y列没有检索到确切的结果。你能帮帮我吗

SELECT FAPI.*, 
       CASE WHEN (SELECT DISTINCT 'Y' 
                    FROM FLOOR_PI FAPI,     
                         NUATON NUMF
                   WHERE FAPI.BRCH = NUMF.BRCH 
                     AND FAPI.BASE = NUMF.BASE 
                     AND FAPI.NUM = 0 
                     AND NVL(FAPI.RATION, 'X') <> 'D' 
                     AND FAPI.CODE = 'A'  
                     AND NUMF.R_DATE 
                          BETWEEN FAPI.EFF_DATE 
                              AND FAPI.EXP_DATE ) = 'Y' 
            THEN 'Y' 
            ELSE 'N' END NEW 
 FROM FLOOR_PI FAPI

谢谢你, Rave的

1 个答案:

答案 0 :(得分:0)

基于@SlimsGohst评论: 您应该用适用的FAPI1或FAPI2替换FAPIx

SELECT FAPI1.*, 
       CASE WHEN (SELECT DISTINCT 'Y' 
                    FROM FLOOR_PI FAPI2,     
                         NUATON NUMF
                   WHERE FAPIx.BRCH = NUMF.BRCH 
                     AND FAPIx.BASE = NUMF.BASE 
                     AND FAPIx.NUM = 0 
                     AND NVL(FAPIx.RATION, 'X') <> 'D' 
                     AND FAPIx.CODE = 'A'  
                     AND NUMF.R_DATE 
                          BETWEEN FAPIx.EFF_DATE 
                              AND FAPIx.EXP_DATE ) = 'Y' 
            THEN 'Y' 
            ELSE 'N' END NEW 
 FROM FLOOR_PI FAPI1