在现在的PMS5.0.1版本中,利用SQL查询每个月的停车时长分布,可利用该数据分析车场运营情况,针对现有的收费规则进行调整,最大化实现营收与便民的平衡。
WITH ranges AS (
SELECT 0 AS start, 60 AS end, '0-1小时' AS label, 1 AS sort_order
UNION ALL
SELECT 61 AS start, 120 AS end, '1-2小时' AS label, 2 AS sort_order
UNION ALL
SELECT 121 AS start, 180 AS end, '2-3小时' AS label, 3 AS sort_order
UNION ALL
SELECT 181 AS start, 240 AS end, '3-4小时' AS label, 4 AS sort_order
UNION ALL
SELECT 241 AS start, 300 AS end, '4-5小时' AS label, 5 AS sort_order
UNION ALL
SELECT 301 AS start, 360 AS end, '5-6小时' AS label, 6 AS sort_order
UNION ALL
SELECT 361 AS start, 420 AS end, '6-7小时'AS label ,7 as sort_order
UNION ALL
SELECT 421 as start ,480 as end,'7-8小时'AS label ,8 as sort_order
UNION ALL
SELECT 481 as start ,540 as end,'8-9小时'AS label ,9 as sort_order
UNION ALL
SELECT 541 as start ,600 as end,'9-10小时'AS label ,10 as sort_order
UNION ALL
SELECT 601 as start ,660 as end,'10-11小时'AS label ,11 as sort_order
UNION ALL
SELECT 661 as start ,720 as end,'11-12小时'AS label ,12 as sort_order
UNION ALL
SELECT 721 as start ,780 as end,'12-13小时'AS label ,13 as sort_order
UNION ALL
SELECT 781 as start ,840 as end,'13-14小时'AS label ,14 as sort_order
UNION ALL
SELECT 841 as start ,900 as end,'14-15小时'AS label ,15 as sort_order
UNION ALL
SELECT 901 as start ,960 as end,'15-16小时'AS label ,16 as sort_order
UNION ALL
SELECT 961 as start ,1020 as end,'16-17小时'AS label ,17 as sort_order
UNION ALL
SELECT 1021 as start ,1080 as end,'17-18小时'AS label ,18 as sort_order
UNION ALL
SELECT 1081 as start ,1140 as end,'18-19小时'AS label ,19 as sort_order
UNION ALL
SELECT 1141 as start ,1200 as end,'19-20小时'AS label ,20 as sort_order
UNION ALL
SELECT 1201 as start ,1260 as end,'20-21小时'AS label ,21 as sort_order
UNION ALL
SELECT 1261 as start ,1320 as end,'21-22小时'AS label ,22 as sort_order
UNION ALL
SELECT 1321 as start ,1380 as end,'22-23小时'AS label ,23 as sort_order
UNION ALL
SELECT 1381 as start, 1440 as end,'23-24小时'AS label ,24 as sort_order
UNION ALL
SELECT 1441 as start, null as end,'24小时以上'AS label ,25 as sort_order
)
SELECT
ranges.label AS "时间区间",
COUNT ( * ) AS "数量"
FROM
charginginfo
JOIN ranges ON parkingduration >= ranges.START
AND ( parkingduration <= ranges.END OR ranges.END IS NULL )
WHERE
TO_CHAR( intime, 'YYYY-MM' ) = '2023-06' --查询月份,可自行变更
AND parkingtype != 0 --排除固定车,可根据现场实际情况变更
GROUP BY
ranges.label,
ranges.sort_order
ORDER BY
ranges.sort_order;
评论前必须登录!
注册