I have two table
table one is scheduletime
id | edition | time |
1 | 1 | 9:23am |
2 | 2 | 10:23am|
Try this:
SELECT
'Scheduleed' AS Caption,
Edition,
time
FROM scheduletime
UNION ALL
SELECT
'actual' AS Caption,
Edition,
time
FROM actualtime
ORDER BY Edition, Caption DESC
OUTPUT:
| CAPTION | EDITION | TIME |
----------------------------------
| Scheduleed | 1 | 9:23am |
| actual | 1 | 10:23am |
| Scheduleed | 2 | 10:23am |
| actual | 2 | 11:23am |
You can use :-
select * from(
select 'Scheduleed' as Caption ,edition,time from scheduletime
union all
select 'actual' as Caption,edition,time from actualtime
)x
select * from
(select 'Scheduleed' as Caption, Edition as Edition, Time as Time from scheduletime
union all
select 'actual' as Caption, Edition as Edition, Time as Time from actualtime) as a
order by Edition
Maybe this will help you
SELECT Caption, Edition, Time
FROM
(
SELECT 'Scheduled' Caption, Edition, time
FROM scheduleTime
UNION ALL
SELECT 'Actual' Caption, Edition, time
FROM scheduleTime
) subquery
ORDER BY Edition, FIELD(Caption, 'Scheduled', 'Actual')
OUTPUT
╔═══════════╦═════════╦═════════╗
║ CAPTION ║ EDITION ║ TIME ║
╠═══════════╬═════════╬═════════╣
║ Scheduled ║ 1 ║ 9:23am ║
║ Actual ║ 1 ║ 9:23am ║
║ Scheduled ║ 2 ║ 10:23am ║
║ Actual ║ 2 ║ 10:23am ║
╚═══════════╩═════════╩═════════╝