Please help me to get expected output below. My requirement order by date am then date pm
select d from(
SELECT TO_CHAR(
TO_DATE('15/August/2009,4:30:00 PM'
,'DD/Month/YYYY,HH:MI:ss AM')
,'DD-MM-YYYY HH:MI:ss AM') as d
FROM DUAL
union all
SELECT TO_CHAR(
TO_DATE('15/August/2009,5:30:00 AM'
,'DD/Month/YYYY,HH:MI:ss AM')
,'DD-MM-YYYY HH:MI:ss AM')as d
FROM DUAL
union all
SELECT TO_CHAR(
TO_DATE('15/August/2009,6:30:00 PM'
,'DD/Month/YYYY,HH:MI:ss AM')
,'DD-MM-YYYY HH:MI:ss AM')as d
FROM DUAL
union all
SELECT TO_CHAR(
TO_DATE('15/August/2009,7:30:00 pM'
,'DD/Month/YYYY,HH:MI:ss AM')
,'DD-MM-YYYY HH:MI:ss AM')as d
FROM DUAL) order by d ;
I am getting following output for the above query in the below.
Actual output
--------------------------
15-08-2009 04:30:00 PM
15-08-2009 05:30:00 AM
15-08-2009 06:30:00 PM
15-08-2009 07:30:00 PM
How to modify the above query to get the below output. Basically i need to order by am and then pm
expected output
--------------------------
15-08-2009 05:30:00 AM
15-08-2009 04:30:00 PM
15-08-2009 06:30:00 PM
15-08-2009 07:30:00 PM