答案 0 :(得分:1)
您可以使用查询生成所有半小时间隔的列表:
SELECT TO_CHAR( TO_DATE( '0601', 'HH24MI' ) + (LEVEL - 1)/48, 'HH24MI' ) AS timeslot
FROM DUAL
CONNECT BY
LEVEL <= 33;
然后,您可以使用LEFT OUTER JOIN
将其添加到查询中;像这样的东西:
WITH half_hours AS (
SELECT TO_CHAR( TO_DATE( '0601', 'HH24MI' ) + (LEVEL - 1)/48, 'HH24MI' ) AS timeslot
FROM DUAL
CONNECT BY
LEVEL <= 33
), data AS (
<your_query>
)
SELECT h.timeslot,
COALESCE( d.value, 0 ) AS value
FROM half_hours h
LEFT OUTER JOIN data d
ON h.timeslot = d.timeslot;