嗨,目前我有代码,它将以 10 分钟的间隔显示最后一小时的记录总和。
SELECT SUM(NO_OF_ADULT) AS ADULT
, SUM(NO_OF_ADULT_F) AS ADULT_F
, SUM(NO_OF_CHILDREN) AS CHILDREN
, SUM(NO_OF_CHILDREN_F) AS CHILDREN_F
, SUM(NO_OF_SENIOR_CITIZEN) AS SENIOR
, SUM(NO_OF_SENIOR_CITIZEN_F) AS SENIOR_F
, SUM(NO_OF_INFANT) AS INFANT
, SUM(NO_OF_INFANT_F) AS INFANT_F
, SUBSTR(END_TIME_OF_SERVICE, 1, 4) || '0 - ' || SUBSTR(END_TIME_OF_SERVICE, 1, 4) || '9' AS TIME_SLOT
FROM CLNT_RESERVATION RES
, CLNT_ORDER ORD
, CLNT_ORDER_CHEQUE_RESERVATION_MAPPING RM
WHERE RES.START_DATE_OF_SERVICE ="2012-09-24"
AND ORD.ENT_CODE="****"
AND ORD.BRANCH_CODE="******"
AND ORD.STATION_CODE="*******"
AND RES.STATION_CODE=ORD.STATION_CODE
AND ORD.ORDER_STATUS <> 111
AND ORD.ORDER_ID=RM.ORDER_ID
AND (ORD.CREATE_TIME LIKE "2012-09-24%" OR ORD.UPDATE_TIME LIKE "2012-09-24%")
AND ORD.STATUS_FLG ="A"
AND ORD.DELETE_FLG="N"
AND RM.RESERVATION_ID = RES.RESERVATION_ID
AND (strftime("%H:%M", RES.END_TIME_OF_SERVICE) BETWEEN strftime("%H:%M",TIME("now","localtime","-1 hour","-00 minutes"))
AND strftime ("%H:%M",TIME("now","localtime")) OR strftime("%H:%M", RES.END_TIME_OF_SERVICE) BETWEEN strftime("%H:%M",TIME("now","localtime","-1 hour","-00 minutes"))
AND strftime("%H:%M",TIME("now","localtime")) )
GROUP BY 9
这将给出以下输出
ADULT ADULT_F CHILDREN CHILDREN_F SENIOR SENIOR_F INFANT INFANT_F TIME_SLOT
0 0 0 0 1 1 0 0 12:00 - 12:09
1 0 0 0 0 1 0 0 12:30 - 12:39
现在您可以看到 12:10 - 12:29 的值不在数据库中,因此也不会显示。
我期待的是: - 1)需要创建行并在所有字段中简单地填写 0。(high) 2) time_slot 应该从当前的 time_stamp 计算。(medium)
帮助这很有帮助,请给我一些解决方案,非常感谢您的时间。