charge_business_analysis.txt 541 B

123456789101112131415161718
  1. -- 收费业务分析
  2. -- 收费数据分析
  3. -- 收费金额
  4. select
  5. t.car_park_name,
  6. case when sum(amount) is null then 0 else round(sum(amount)/100,2) end +30 as reality_amount, -- 应收金额
  7. case when sum(amount) is null then 0 else round(sum(amount)/100,2) end as amount -- 实收金额
  8. FROM
  9. luo_parking_information t
  10. left join
  11. (select a.park_id,a.pay_time,b.amount
  12. from luo_parking_chargerecord a
  13. inner join luo_parking_chargerecord_subject b
  14. on a.order_no=b.order_no) c
  15. ON t.id = c.park_id
  16. group by 1
  17. HAVING sum(amount)>0