如果sci.source=“cc”,则sci.category不应为“not waiting”我想根据这个附加条件归还记录

3qpi33ja  于 2021-07-24  发布在  Java
关注(0)|答案(2)|浏览(174)
SELECT DISTINCT sci.le_id AS le_id,
                sci.sub_profile_id AS sub_profile_id,
                sci.GROUP_ID AS GROUP_ID,
                sci.cdd_id,
                sci.crm_id,
                sci.grp_crm_id,
                sci.source,
                sci.category
  FROM table_name sci
 WHERE sci.crm_id IN (SELECT master.x_ref_id
                        FROM biz_master master, biz_pr_master pr
                       WHERE     master.x_latest_txn_id = pr.x_txn_id
                             AND pr.x_leid IS NULL
                             AND pr.GROUP_ID IS NULL)
mrphzbgm

mrphzbgm1#

我在想 CASE :

and sci.category <> case when sci.source = 'CC' then 'not awaiting'
                         else '???
                    end
zysjyyx4

zysjyyx42#

然后把它加到 WHERE 条款如下:

WHERE ......
  AND (sci.source <> 'CC' -- this condition will be true for all other sci.source
  OR sci.category <> 'not awaiting') -- This condition will be checked if sci.source = CC

相关问题