I have a problem that is quite simple to understand, but for me it is not that simple to implement.
I have a table named Time:
-----------------------------------
DAY TIME1 TIME2
-----------------------------------
1 08.00 09.40
1 09.40 10.00
1 10.00 11.40
2 08.00 08.50
2 08.50 10.40
----------------------------------
What I want to get is like:
-------------------
DAY TIME
-------------------
1 08.00
1 09.40
1 10.00
1 11.00
2 08.00
2 08.50
2 10.40
------------------
I have tried this code:
SELECT DISTINCT sub.val FROM (
SELECT Time1 AS val FROM Time
UNION ALL
SELECT Time2 AS val FROM Time
) AS sub
And it is only return the Time column. I have no idea about joining the “Day” column. While I am trying to add the “Day” after the “DISTINCT sub.val”, it got error. How to do it?
Thank you very much.
1 Answer