各时间段出入场信息.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. -- 按小时统计入场
  2. select
  3. time_id,
  4. ifnull(park_num,0) as park_num
  5. from
  6. luo_time_data b
  7. left join
  8. (select
  9. hour(in_time) in_hour,
  10. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  11. from
  12. luo_park_baseinfo t
  13. LEFT JOIN luo_parking_inrecord a
  14. ON t.park_id = a.park_id
  15. WHERE
  16. t.area_id = '411102'
  17. AND t.keys_areas = '商圈'
  18. AND t.street_name LIKE '%人民%'
  19. group by 1
  20. order by 1) c
  21. on b.time_id=c.in_hour
  22. -- 按小时统计出场
  23. select
  24. time_id,
  25. ifnull(park_num,0) as park_num
  26. from
  27. luo_time_data b
  28. left join
  29. (select
  30. hour(out_time) out_hour,
  31. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  32. from
  33. luo_park_baseinfo t
  34. LEFT JOIN luo_parking_outrecord a
  35. ON t.park_id = a.park_id
  36. WHERE
  37. t.area_id = '411102'
  38. AND t.keys_areas = '商圈'
  39. AND t.street_name LIKE '%人民%'
  40. group by 1
  41. order by 1) c
  42. on b.time_id=c.out_hour
  43. -- 按日统计入场
  44. select
  45. day(in_time) in_day,
  46. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  47. from
  48. luo_park_baseinfo t
  49. LEFT JOIN luo_parking_inrecord a
  50. ON t.park_id = a.park_id
  51. WHERE
  52. t.area_id = '411102'
  53. AND t.keys_areas = '商圈'
  54. AND t.street_name LIKE '%人民%'
  55. group by 1
  56. order by 1
  57. -- 按日统计出场
  58. select
  59. day(out_time) in_day,
  60. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  61. from
  62. luo_park_baseinfo t
  63. LEFT JOIN luo_parking_outrecord a
  64. ON t.park_id = a.park_id
  65. WHERE
  66. t.area_id = '411102'
  67. AND t.keys_areas = '商圈'
  68. AND t.street_name LIKE '%人民%'
  69. group by 1
  70. order by 1
  71. -- 按周统计入场
  72. select
  73. WEEKDAY(in_time)+1 as week_day,
  74. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  75. from
  76. luo_park_baseinfo t
  77. LEFT JOIN luo_parking_inrecord a
  78. ON t.park_id = a.park_id
  79. WHERE
  80. t.area_id = '411102'
  81. AND t.keys_areas = '商圈'
  82. AND t.street_name LIKE '%人民%'
  83. group by 1
  84. order by 1
  85. -- 按周统计出场
  86. select
  87. WEEKDAY(out_time)+1 as week_day,
  88. case when count(parking_no) is null then 0 else count(parking_no) end as park_num
  89. from
  90. luo_park_baseinfo t
  91. LEFT JOIN luo_parking_outrecord a
  92. ON t.park_id = a.park_id
  93. WHERE
  94. t.area_id = '411102'
  95. AND t.keys_areas = '商圈'
  96. AND t.street_name LIKE '%人民%'
  97. group by 1
  98. order by 1
  99. -- 按年统计入场
  100. SELECT YEAR
  101. ( in_time ) AS week_day,
  102. CASE
  103. WHEN count( parking_no ) IS NULL THEN
  104. 0 ELSE count( parking_no )
  105. END AS park_num
  106. FROM
  107. luo_park_baseinfo t
  108. LEFT JOIN luo_parking_inrecord a ON t.park_id = a.park_id
  109. AND t.area_id = '411102'
  110. AND t.keys_areas = '商圈'
  111. AND t.street_name LIKE '%人民%'
  112. GROUP BY 1
  113. ORDER BY 1
  114. -- 按年统计出场
  115. SELECT YEAR
  116. ( out_time ) AS week_day,
  117. CASE
  118. WHEN count( parking_no ) IS NULL THEN
  119. 0 ELSE count( parking_no )
  120. END AS park_num
  121. FROM
  122. luo_park_baseinfo t
  123. LEFT JOIN luo_parking_outrecord a ON t.park_id = a.park_id
  124. AND t.area_id = '411102'
  125. AND t.keys_areas = '商圈'
  126. AND t.street_name LIKE '%人民%'
  127. GROUP BY 1
  128. ORDER BY 1