clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1579708 fiddles created (21388 in the last week).

CREATE TABLE tablename (RESERVATION int, PREFIX varchar2(2), FLIGHT int, ORIGIN varchar2(3), DESTINATION varchar2(3), DATE_FLIGHT timestamp) ;
 hidden batch(es)


INSERT ALL INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 123, 'LAX', 'MIA', '01-Feb-2020 12:00:00 AM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 122, 'MIA', 'SCL', '01-Feb-2020 10:30:00 AM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 667, 'MIA', 'SCL', '03-Feb-2020 02:15:00 PM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 882, 'SCL', 'ARG', '03-Feb-2020 04:00:00 PM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 111, 'SCL', 'ARG', '03-Feb-2020 11:00:00 PM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 966, 'SCL', 'ARG', '03-Feb-2020 11:30:00 PM') INTO tablename (RESERVATION, PREFIX, FLIGHT, ORIGIN, DESTINATION, DATE_FLIGHT) VALUES (111, 'LA', 622, 'SCL', 'ARG', '05-Feb-2020 08:00:00 AM') SELECT * FROM dual ;
7 rows affected
 hidden batch(es)


select t.RESERVATION, t1.PREFIX PREFIX_min, t1.FLIGHT FLIGHT_min, t1.ORIGIN ORIGIN_min, t1.DESTINATION DESTINATION_min, t1.DATE_FLIGHT DATE_FLIGHT_min, t2.PREFIX PREFIX_max, t2.FLIGHT FLIGHT_max, t2.ORIGIN ORIGIN_max, t2.DESTINATION DESTINATION_max, t2.DATE_FLIGHT DATE_FLIGHT_max from ( select RESERVATION, min(DATE_FLIGHT) DATE_FLIGHT_min, max(DATE_FLIGHT) DATE_FLIGHT_max from tablename group by RESERVATION ) t inner join tablename t1 on t1.RESERVATION = t.RESERVATION AND t1.DATE_FLIGHT = t.DATE_FLIGHT_min inner join tablename t2 on t2.RESERVATION = t.RESERVATION AND t2.DATE_FLIGHT = t.DATE_FLIGHT_max
RESERVATION PREFIX_MIN FLIGHT_MIN ORIGIN_MIN DESTINATION_MIN DATE_FLIGHT_MIN PREFIX_MAX FLIGHT_MAX ORIGIN_MAX DESTINATION_MAX DATE_FLIGHT_MAX
111 LA 123 LAX MIA 01-FEB-20 12.00.00.000000 AM LA 622 SCL ARG 05-FEB-20 08.00.00.000000 AM
 hidden batch(es)