berth_peration_nalysis.txt 998 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. -- 泊位运营分析
  2. -- 停车数
  3. SELECT
  4. park_name,
  5. CASE
  6. WHEN
  7. sum( remain_parking_number ) IS NULL THEN
  8. 0 ELSE sum( remain_parking_number )
  9. END remain_parking_number-- 空闲位
  10. FROM
  11. luo_park_baseinfo t
  12. LEFT JOIN luo_parking_berths a ON t.park_id = a.park_id
  13. AND a.CREATE_TIME = ( SELECT max( CREATE_TIME ) max_time FROM luo_parking_berths )
  14. group by 1
  15. -- 平均周转次数
  16. select c.car_park_name,
  17. round(avg(parking_turnover_rate),2) as parking_turnover_rate
  18. from
  19. luo_parking_information c inner join
  20. (SELECT
  21. t.park_id,
  22. b.total_parking_number,
  23. count( t.parking_no ) AS parking_num,
  24. count( t.parking_no )/b.total_parking_number as parking_turnover_rate
  25. FROM
  26. luo_parking_inrecord t
  27. inner join luo_parking_berths b on t.park_id = b.park_id and b.CREATE_TIME = (
  28. SELECT
  29. max( CREATE_TIME ) max_time
  30. FROM
  31. luo_parking_berths
  32. WHERE
  33. create_time >= curdate())
  34. where in_time>=CURDATE()
  35. GROUP BY
  36. t.park_id,
  37. b.total_parking_number) t1
  38. on c.id=t1.park_id
  39. GROUP BY 1