一则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 


存在加班工资发放不足隐患|无证照经营

转载于:https://www.cnblogs.com/samlin/archive/2009/05/22/1487248.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值