zoukankan      html  css  js  c++  java
  • MS SQLSESRVER 第一次

     select o.orgname,t3.sumb,b.period,b.balamt,b.busdate,b.createdate
     from new_jsjg_ie.dbo.iest_balance b,new_jsjg_ie.dbo.iecm_org o,
    (select   orgname+max(period) nm,sum(b.balamt) sumb
     from new_jsjg_ie.dbo.iest_balance b,new_jsjg_ie.dbo.iecm_org o
     where b.orgid=o.id and b.balamt<>0 group by  o.orgname)t3
    where b.orgid=o.id
    and  o.orgname+b.period=nm  order by period desc

    1.9号更新,增加所属分公司

    select (select  orgname from new_jsjg_ie.dbo.iecm_org  where id=c.locationindeprid) 所属分公司,
     c.contractno 合同编码,o.orgname 项目名称,
    convert(varchar(100),c.planstartdate,23)合同开始时间,
    convert(varchar(100),c.planenddate,23)合同结束时间,
    convert(varchar(100),convert(decimal(18,2),c.contractcost))+''  合同额,
    convert(varchar(100),convert(decimal(18,2),t3.sumb/10000))+'' 开累业主计量,
    b.period 最新月,convert(varchar(100),convert(decimal(18,2),b.balamt/10000))+'' 最新月业主计量,
    convert(varchar(100),b.busdate,23) 建账日期
     from new_jsjg_ie.dbo.iest_balance b,new_jsjg_ie.dbo.iecm_org o, new_jsjg_ie.dbo.iect_contract c ,
    (select   orgname+max(period) nm,sum(b.balamt) sumb
     from new_jsjg_ie.dbo.iest_balance b,new_jsjg_ie.dbo.iecm_org o 
     where b.orgid=o.id and b.balamt<>0 group by  o.orgname)t3
    where b.orgid=o.id
          and o.id=c.orgid
          and  o.orgname+b.period=nm
          and c.contracttype='P1'
      order by period desc

  • 相关阅读:
    Saltstack module apache 详解
    Saltstack module ip 详解
    Saltstack module iosconfig 详解
    Saltstack module introspect 详解
    Saltstack module inspector 详解
    Saltstack module ini 详解
    Saltstack module incron 详解
    Modbus 指令 RS485指令规则
    停车系统对接第三方在线支付平台(二)
    停车系统对接第三方在线支付平台
  • 原文地址:https://www.cnblogs.com/sumsen/p/2851535.html
Copyright © 2011-2022 走看看