• 对一个sql的分析


     select *
       FROM LPEdorItem a, LCCont b, LPEdorApp c
      WHERE a.edoracceptno = c.edoracceptno
        and a.ContNo = b.ContNo
        and b.appntno = '0000235356'
        AND b.conttype = '1' --'2-集体总单,1-个人总投保单';
        AND (c.AppType != '6' OR c.AppType is null) -- 申请方式
        and a.edorvalidate >= trunc(sysdate) - 365
        and a.edorvalidate <= trunc(sysdate)
        and c.makedate between to_date('20190101', 'yyyy-mm-dd') and
            to_date('20201117', 'yyyy-mm-dd')
        and b.familytype <> '1'
        and (case
              when a.edorstate in ('0', 'j', '4', '9', 'c', 'd') and
                   (not exists (select 1
                                  from ljaget t
                                 where t.otherno = a.edoracceptno
                                   and t.confdate is null
                                   and t.sumgetmoney <> 0) or EXISTS
                    (SELECT 1
                       FROM LJMONETARYSTERILIZATIONB LJM
                      WHERE LJM.OTHERNO = A.contno)) then
               '1'
              else
               '0'
            end) = '1'
    

     简化

    -->>>>这两个是等同的
    select *
      from LPEdorItem a
     where (case
             when a.edorstate in ('0', 'j', '4', '9', 'c', 'd')then
              '1'
             else
              '0'
           end) = '1'
    --------------------------------------------------------------------------------
    select * from LPEdorItem a where a.edorstate in ('0', 'j', '4', '9', 'c', 'd')
    

     解释: { when 条件 then '1'}= '1' 这等同于where条件  where a.edorstate in ('0', 'j', '4', '9', 'c', 'd')

    select *
      from LPEdorItem a
     where (not exists (select 1
                          from ljaget t --实付总表
                         where t.otherno = a.edoracceptno
                           and t.confdate is null  --财务确认日期
                           and t.sumgetmoney <> 0) --总给付金额
                            or EXISTS 
            (SELECT 1
               FROM LJMONETARYSTERILIZATIONB LJM
              WHERE LJM.OTHERNO = A.contno))
    

     再简化 

     

  • 相关阅读:
    clickhouse群集模式搭建
    基于Att&ck模型的整体威胁框架方法论
    应急响应Windows各种操作记录备份
    代理总结
    Linux应急响应日志分析
    Web漏洞利用框架
    Suricata策略记录
    应急响应汇总
    IDS&IPSSuricata介绍
    ATT&CKMitreInitial Access(初始化访问)
  • 原文地址:https://www.cnblogs.com/zytcomeon/p/13999468.html
Copyright © 2020-2023  润新知