SELECT Q1.SJ AS DATATIME,NVL(A.WD,0) AS DATA FROM (SELECT ROWNUM || ':00' SJ FROM DUAL CONNECT BY ROWNUM <= 24) Q1,
(SELECT SJ,NVL(WD,0) AS WD,RQ FROM YYGX_XM WHERE CS = 'Test') A
WHERE Q1.SJ = A.SJ(+) AND TO_CHAR(A.RQ, 'yyyy-MM-dd') = '2015-06-10'
ORDER BY DECODE(DATATIME,
'9:00',
'1',
'10:00',
'11',
'11:00',
'12',
'12:00',
'13',
'13:00',
'14',
'14:00',
'15',
'15:00',
'16',
'16:00',
'17',
'17:00',
'18',
'18:00',
'19',
'19:00',
'20',
'20:00',
'21',
'21:00',
'22',
'22:00',
'23',
'23:00',
'24',
'24:00',
'25',
'1:00',
'26',
'2:00',
'27',
'3:00',
'28',
'4:00',
'29',
'5:00',
'30',
'6:00',
'31',
'7:00',
'32',
'8:00',
'33',
DATATIME);