时间:2017-11-06 03:08:36

标签: oracle-sqldeveloper

我需要你们帮助我完成任务。

1

SELECT * FROM DBMGR.RTREDC00
WHERE EDC_PARM = '9940-RESOE'
AND EDC_LOT = 'H28BRAD'` 

enter image description here

2

SELECT LSPEC.GET_LSPEC_MIN((SELECT RL_PO FROM DBMGR.RTRLOT01 WHERE 
    RL_FACILITY = 'MKLPROD' AND RL_LOT = 'H28BRAD'),'9940-RES','M') MIN_RAS,
    LSPEC.GET_LSPEC_MAX((SELECT RL_PO FROM DBMGR.RTRLOT01 WHERE RL_FACILITY 
    = 'MKLPROD' AND RL_LOT = 'H28BRAD'),'9940-RES','M') MAX_RAS
    FROM DUAL

enter image description here

我需要使用CASE WHEN创建语法,edc_valueMIN_RAS之间的MAX_RAS输出将为空,如果edc_value不在MIN_RAS之间{1}}和MAX_RAS输出将为edc_lot

1 个答案:

答案 0 :(得分:0)

我相信这就是你要找的东西。

 --solution using common table expression and cross join
 WITH
      B AS ( --B for BOUNDS
           SELECT
                LSpec.Get_lspec_min(
                     (
                     SELECT rl_po 
                     FROM DBMgr.rtrlot01 
                     WHERE rl_facility = 'MKLPROD' 
                          AND rl_lot = 'H28BRAD'
                     ),
                     '9940-RES',
                     'M'
                ) AS min_ras, 
                LSpec.Get_lspec_max(
                     (
                     SELECT rl_po 
                     FROM DBMgr.rtrlot01 
                     WHERE rl_facility = 'MKLPROD' 
                          AND rl_lot = 'H28BRAD'
                     ),
                     '9940-RES',
                     'M'
                ) AS max_ras 
           FROM   dual
      )

 SELECT
      R.edc_facility,
      R.edc_parm,
      R.edc_lot,
      R.edc_unit,
      R.edc_waf_id,
      R.edc_seq,
      R.edc_value,
      CASE
           WHEN R.edc_value >= B.min_ras AND edc_value <= B.max_ras THEN NULL
           ELSE R.edc_lot
      END AS logic_requirement -- here is your requirement
 FROM DBMgr.RTREDC00 R
 CROSS JOIN B
 WHERE R.edc_parm = '9940-RESOE'
      AND R.edc_lot = 'H28BRAD'
 ;


 --solution using scalar subqueries within CASE statement of SELECT clause
 SELECT
      R.edc_facility,
      R.edc_parm,
      R.edc_lot,
      R.edc_unit,
      R.edc_waf_id,
      R.edc_seq,
      R.edc_value,
      CASE
           WHEN      edc_value >= (
                                    SELECT
                                         LSpec.Get_lspec_min(
                                              (
                                              SELECT rl_po 
                                              FROM DBMgr.rtrlot01 
                                              WHERE rl_facility = 'MKLPROD' 
                                                   AND rl_lot = 'H28BRAD'
                                              ),
                                              '9940-RES',
                                              'M'
                                         )
                                    FROM Dual
                                    )
                AND  edc_value <= (
                                    SELECT
                                         LSpec.Get_lspec_max(
                                              (
                                              SELECT rl_po 
                                              FROM DBMgr.rtrlot01 
                                              WHERE rl_facility = 'MKLPROD' 
                                                   AND rl_lot = 'H28BRAD'
                                              ),
                                              '9940-RES',
                                              'M'
                                         ) AS max_ras 
                                    FROM Dual
                                    )
                THEN NULL
           ELSE edc_lot
      END AS logic_requirement            
 FROM DBMgr.RTREDC00
 WHERE edc_parm = '9940-RESOE'
      AND edc_lot = 'H28BRAD'
 ;