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 


    存在加班工资发放不足隐患|无证照经营
  • 相关阅读:
    MSSQL Rebuild(重建)索引
    网络爬虫原理
    Twitter Storm:单机环境的安装与配置
    1079 回家
    Win2003 Server磁盘配额揭密之补遗篇
    Win2003 Server磁盘配额揭密之启用篇
    编译mapnik(win7 环境下vs2008编译mapnik 0.7.1 成功)
    Writing a Windows Shell Extension(marco cantu的博客)
    Android学习之一:Cygwin简介
    Linux 进程间通信(一)
  • 原文地址:https://www.cnblogs.com/samlin/p/1487248.html
Copyright © 2011-2022 走看看