berth_recommend.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. -- 各区域停车缺口
  2. select street_name,
  3. parking_gap_rate
  4. from
  5. (select
  6. t2.street_name,
  7. ifnull(round(count(case when t2.occupancy_rate>90 then park_id end)/count(t2.park_id),2),0)*100 as
  8. parking_gap_rate
  9. from
  10. (SELECT
  11. t.street_name,
  12. t.park_id,
  13. ifnull(a.total_parking_number,0) as total_parking_number,
  14. ifnull(a.remain_parking_number,0) as remain_parking_number,
  15. ifnull(round(remain_parking_number*100/total_parking_number,2),0) as occupancy_rate
  16. FROM
  17. luo_park_baseinfo t
  18. LEFT JOIN luo_parking_berths a ON t.park_id = a.park_id
  19. AND a.CREATE_TIME >= ( SELECT max( CREATE_TIME ) max_time FROM luo_parking_berths )
  20. where t.street_name !=''
  21. and remain_parking_number>=0) t2
  22. group by 1) t3
  23. where parking_gap_rate>0
  24. -- 各区域路内泊位
  25. select area_name,
  26. parking_gap_rate
  27. from
  28. (select
  29. t2.area_name,
  30. ifnull(round(count(case when t2.occupancy_rate>90 then park_id end)/count(t2.park_id),2),0)*100 as
  31. parking_gap_rate
  32. from
  33. (SELECT
  34. t.area_name,
  35. t.park_id,
  36. ifnull(a.total_parking_number,0) as total_parking_number,
  37. ifnull(a.remain_parking_number,0) as remain_parking_number,
  38. ifnull(round(remain_parking_number*100/total_parking_number,2),0) as occupancy_rate
  39. FROM
  40. luo_park_baseinfo t
  41. LEFT JOIN luo_parking_berths a ON t.park_id = a.park_id
  42. AND a.CREATE_TIME >= ( SELECT max( CREATE_TIME ) max_time FROM luo_parking_berths )
  43. where remain_parking_number>=0) t2
  44. group by 1) t3