IDC报表.sql 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. select * from
  2. (select smonth,sname,idc_in_total,idc_in_jtft,idc_in_qzc,(idc_in_total-idc_in_jtft-idc_in_qzc) as chazhi
  3. from sqmdb_cost.chengben_shengnei where smonth='202203' and stype='地市') byue
  4. join
  5. (select smonth,sname,idc_in_total,idc_in_jtft,idc_in_qzc,(idc_in_total-idc_in_jtft-idc_in_qzc) as chazhi
  6. from sqmdb_cost.chengben_shengnei where smonth='202202' and stype='地市') syue
  7. on byue.sname=syue.sname
  8. --create table sqmdb_cost.rpt_tmp as
  9. select smonth,sname,'IDC业务收入' as vtype,idc_in_total as amount from sqmdb_cost.chengben_shengnei where smonth='202203' and stype='地市'
  10. union all
  11. select smonth,sname,'集团分摊收入' as vtype,idc_in_jtft as amount from sqmdb_cost.chengben_shengnei where smonth='202203' and stype='地市'
  12. union all
  13. select smonth,sname,'轻资产运营收入' as vtype,idc_in_qzc as amount from sqmdb_cost.chengben_shengnei where smonth='202203' and stype='地市'
  14. union all
  15. select smonth,sname,'减去分摊及轻资产收入' as vtype,(idc_in_total-idc_in_jtft-idc_in_qzc) as amount from sqmdb_cost.chengben_shengnei where smonth='202203' and stype='地市'
  16. select sname,
  17. sum(column4+column5)*0.1512/10000 as id_19,
  18. sum(column4+column5)*0.8488/10000 as id_20,
  19. sum(column19)/10000 as id_21,
  20. sum(column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)/10000 as id_23,
  21. sum(column108)/10000 as id_24,
  22. sum(column5)/10000 as id_25_p2
  23. from sqmdb_cost.report50 r
  24. where period_type='M' and smonth between '202201' and '202207' and stype='分省展现' and sname ='河北' group by sname
  25. union all
  26. select sname,
  27. (column4+column5)*0.1512/10000 as id_19,
  28. (column4+column5)*0.8488/10000 as id_20,
  29. (column19)/10000 as id_21,
  30. (column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)/10000 as id_23,
  31. (column108)/10000 as id_24,
  32. (column5)/10000 as id_25_p2
  33. from sqmdb_cost.report50 r
  34. where period_type='Y' and smonth='202207' and stype='分省展现' and sname ='河北'
  35. --网运成本专业分解表-归集+横向分摊+调差_年_分省展现_01合并
  36. select * from sqmdb_cost.report50 where sname='河北' and period_type='Y' and smonth='202207'