Firdbird数据库子查询(包含比例)

 string SJ = DateTime.Now.Year.ToString();
            string str =string.Format(@"select first 1
           (select count(*) from OfficialCaseRegisters where FillTime='{0}') as a,
             (select case (select count(*) from OfficialCaseRegisters where  FillTime='{1}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  FillTime='{2}')*100.0 / count(*))
            end  from OfficialCaseRegisters where  FillTime='{3}') as b,
            (select count(*) from OfficialCaseRegisters  where PostName='正处' and FillTime='{4}') as c,
             (select case (select count(*) from OfficialCaseRegisters where PostName='正处' and FillTime='{5}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='正处' and FillTime='{6}')*100.0 / count(*))
            end  from OfficialCaseRegisters where  FillTime='{7}') as d,
              (select count(*) from OfficialCaseRegisters  where  PostName='副处' and FillTime='{8}') as e,
             (select case (select count(*) from OfficialCaseRegisters where  PostName='副处' and FillTime='{9}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='副处' and FillTime='{10}')*100.0 / count(*))
            end  from OfficialCaseRegisters where FillTime='{11}') as f,
            (select count(*) from OfficialCaseRegisters  where  PostName='正科' and  FillTime='{12}') as g,
             (select case (select count(*) from OfficialCaseRegisters where  PostName='正科' and  FillTime='{13}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='正科' and  FillTime='{14}')*100.0 / count(*))
            end  from OfficialCaseRegisters where  FillTime='{15}') as h,
             (select count(*) from OfficialCaseRegisters  where  PostName='副科' and  FillTime='{16}') as j,
             (select case (select count(*) from OfficialCaseRegisters where  PostName='副科' and  FillTime='{17}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='副科' and FillTime='{18}')*100.0 / count(*))
            end  from OfficialCaseRegisters where FillTime='{19}') as k,
            (select count(*) from OfficialCaseRegisters  where  PostName='科办员' and FillTime='{20}') as l,
             (select case (select count(*) from OfficialCaseRegisters where  PostName='科办员' and  FillTime='{21}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='科办员' and  FillTime='{22}')*100.0 / count(*))
            end  from OfficialCaseRegisters where  FillTime='{23}') as z,
             (select count(*) from OfficialCaseRegisters  where  PostName='试用期人员' and  FillTime='{24}') as x,
             (select case (select count(*) from OfficialCaseRegisters where  PostName='试用期人员' and FillTime='{25}')
            when 0 then 0 else((select count(*) from OfficialCaseRegisters where  PostName='试用期人员' and FillTime='{26}')*100.0 / count(*))
            end  from OfficialCaseRegisters where  FillTime='{27}') as v
            from OfficialCaseRegisters ", SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ, SJ);

           参数sj表示查询条件。

转载于:https://www.cnblogs.com/08netsx/archive/2010/08/18/1802822.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值