1234567891011121314151617181920212223242526272829303132333435363738 |
- --11、单业务量移网成本
- ---地市
- select
- cost_t.smonth as MONTH_ID,
- '地市' as ZB_TYPE,
- '河北' as PROV_NAME,
- cost_t.city_code*100 as CITY_ID,
- cost_t.city_name as CITY_NAME,
- null as GRID_ID,
- null as GRID_NAME,
- '11' as ZB_CODE,
- '单业务量移网成本' as ZB_NAME,
- '否' as IS_RATIO,
- cost_t.cost_yw+cost_t.cost_hexin as QZ_FZ,
- ywl_t.yewul as QZ_FM,
- (cost_t.cost_yw+cost_t.cost_hexin)/ywl_t.yewul/7 as BY_QZ
- from
- (select a.smonth,dg.city_name,dg.city_code,a.cost_yw,a.cost_hexin from
- (select '202207' as smonth,sname,
- sum(column2+column3+column4+column5+column6+column7+column8+column9+column10+column11+column12+column13+column14+column15+column16+column17+column18) as cost_yw,
- sum(column19+column20+column21+column22+column23+column24+column25+column26) as cost_hexin
- from sqmdb_cost.report50
- where period_type='M'
- and sname in('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
- and smonth between '202201' and '202207' group by sname) a
- join (select distinct city_code,city_pro,city_name from sqmdb_cost.dict_grid) dg
- on a.sname=dg.city_pro) cost_t
- join
- (select dg.city_name,avg_num(y1.yewul,y2.yewul) as yewul from
- (select city_name,sum(yewul) as yewul from sqmdb_cost.zpzs z where grid_name!='合计' and smonth='202112' group by city_name) y1
- join
- (select city_name,sum(yewul) as yewul from sqmdb_cost.zpzs z where grid_name!='合计' and smonth='202207' group by city_name) y2
- on y1.city_name=y2.city_name
- join
- (select distinct city_sname,city_code,city_name from sqmdb_cost.dict_grid) dg
- on y1.city_name=dg.city_sname) ywl_t
- on cost_t.city_name=ywl_t.city_name
- order by cost_t.city_code
|