zoukankan      html  css  js  c++  java
  • 一则Sql统计的语句

    select * from EnterpriseInfo


    select * ,CharIndex('存在加班工资发放不足隐患|无证照经营',DisputeReason) from LabourCapitalDispute

    select a.*,EnterpriseType from LabourCapitalDispute a left join EnterpriseInfo on EnterpriseName = EnterpriseInfo.name 


    select a.*,EnterpriseType from LabourCapitalDispute a left join EnterpriseInfo b on a.EnterpriseName = b.name 



    select count(1) total 
        ,
    sum(case when b.EnterpriseType='台资企业' then 1 else 0 end) bc_tz --排查企业
        ,Sum(Case When b.EnterpriseType='日资企业' then 1 else 0 end) bc_rz
        ,
    Sum(Case When b.EnterpriseType='其他外资企业' then 1 else 0 end) bc_qtwz
        ,
    Sum(Case When b.EnterpriseType='民营企业' then 1 else 0 end) bc_my
        ,
    Sum(Case When b.EnterpriseType='其他' then 1 else 0 end) bc_qt
        ,
    Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 then 1 else 0 end) tcfj_xj  --调处化解
        ,Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 and b.EnterpriseType='台资企业' then 1 else 0 end) tcfj_tz
        ,
    Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 and b.EnterpriseType='日资企业' then 1 else 0 end) tcfj_rz
        ,
    Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 and b.EnterpriseType='其他外资企业' then 1 else 0 end) tcfj_qtwz
        ,
    Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 and b.EnterpriseType='民营企业' then 1 else 0 end) tcfj_my
        ,
    Sum(Case When CharIndex('调处化解',a.DisputeReason) > 0 and b.EnterpriseType='其他' then 1 else 0 end) tcfj_qt
        ,
    Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 then 1 else 0 end) waht_xj  --未按合同法要求签订劳动合同
        ,Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 and b.EnterpriseType='台资企业' then 1 else 0 end) waht_tz
        ,
    Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 and b.EnterpriseType='日资企业' then 1 else 0 end) waht_rz
        ,
    Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 and b.EnterpriseType='其他外资企业' then 1 else 0 end) waht_qtwz
        ,
    Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 and b.EnterpriseType='民营企业' then 1 else 0 end) waht_my
        ,
    Sum(Case When CharIndex('未按合同法要求签订劳动合同',a.DisputeReason) > 0 and b.EnterpriseType='其他' then 1 else 0 end) waht_qt
        ,
    Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 then 1 else 0 end) czjb_xj  --存在加班工资发放不足隐患
        ,Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 and b.EnterpriseType='台资企业' then 1 else 0 end) czjb_tz
        ,
    Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 and b.EnterpriseType='日资企业' then 1 else 0 end) czjb_rz
        ,
    Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 and b.EnterpriseType='其他外资企业' then 1 else 0 end) czjb_qtwz
        ,
    Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 and b.EnterpriseType='民营企业' then 1 else 0 end) czjb_my
        ,
    Sum(Case When CharIndex('存在加班工资发放不足隐患',a.DisputeReason) > 0 and b.EnterpriseType='其他' then 1 else 0 end) czjb_qt
        ,
    Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 then 1 else 0 end) czqy_xj  --存在企业运营困难隐患
        ,Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 and b.EnterpriseType='台资企业' then 1 else 0 end) czqy_tz
        ,
    Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 and b.EnterpriseType='日资企业' then 1 else 0 end) czqy_rz
        ,
    Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 and b.EnterpriseType='其他外资企业' then 1 else 0 end) czqy_qtwz
        ,
    Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 and b.EnterpriseType='民营企业' then 1 else 0 end) czqy_my
        ,
    Sum(Case When CharIndex('存在企业运营困难隐患',a.DisputeReason) > 0 and b.EnterpriseType='其他' then 1 else 0 end) czqy_qt
        ,
    Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 then 1 else 0 end) wzzj_xj  --无证照经营
        ,Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 and b.EnterpriseType='台资企业' then 1 else 0 end) wzzj_tz
        ,
    Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 and b.EnterpriseType='日资企业' then 1 else 0 end) wzzj_rz
        ,
    Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 and b.EnterpriseType='其他外资企业' then 1 else 0 end) wzzj_qtwz
        ,
    Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 and b.EnterpriseType='民营企业' then 1 else 0 end) wzzj_my
        ,
    Sum(Case When CharIndex('无证照经营',a.DisputeReason) > 0 and b.EnterpriseType='其他' then 1 else 0 end) wzzj_qt
        ,
    Sum(Case When a.IsUnstableAspect = 1 then 1 else 0 end) czqt_xj  --存在其他不稳定因素
        ,Sum(Case When a.IsUnstableAspect = 1 and b.EnterpriseType='台资企业' then 1 else 0 end) czqt_tz
        ,
    Sum(Case When a.IsUnstableAspect = 1 and b.EnterpriseType='日资企业' then 1 else 0 end) czqt_rz
        ,
    Sum(Case When a.IsUnstableAspect = 1 and b.EnterpriseType='其他外资企业' then 1 else 0 end) czqt_qtwz
        ,
    Sum(Case When a.IsUnstableAspect = 1 and b.EnterpriseType='民营企业' then 1 else 0 end) czqt_my
        ,
    Sum(Case When a.IsUnstableAspect = 1 and b.EnterpriseType='其他' then 1 else 0 end) czqt_qt
        ,
    Sum(DealPersonCount) DealPersonCount
    from LabourCapitalDispute
    left join EnterpriseInfo b on a.EnterpriseName = b.name 


    存在加班工资发放不足隐患|无证照经营
  • 相关阅读:
    已知用经纬度表示的两点,求两点之间的直线距离
    linux 管道--转
    Five ways to maximize Java NIO and NIO.2--reference
    java获取当前方法
    事务策略: 了解事务陷阱--转
    实例详解 EJB 中的六大事务传播属性--转
    全面分析 Spring 的编程式事务管理及声明式事务管理--转
    Spring 事务管理高级应用难点剖析--转
    Java NIO——Selector机制源码分析---转
    Java NIO类库Selector机制解析--转
  • 原文地址:https://www.cnblogs.com/samlin/p/1487248.html
Copyright © 2011-2022 走看看