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 


    存在加班工资发放不足隐患|无证照经营
  • 相关阅读:
    ADO.NET 数据连接查询
    弹出消息对话框类
    C# 火星文转化 算法 dictionary 的使用案例
    微软官方的SqlHelper
    jsHelper
    【VC++积累】之六、MFC简要剖析
    C# 统计文章中字符的种类和个数 哈希表和字典的使用
    C# NetHelper
    C# XML操作类 XmlHelper
    【VS++积累】之七、黑客编程之匿名管道
  • 原文地址:https://www.cnblogs.com/samlin/p/1487248.html
Copyright © 2011-2022 走看看