SELECT
s.row,
JSON_AGG(s.seat_no ORDER BY s.seat_no) AS seats,
tf.fare_conditions
FROM
seats s
JOIN
ticket_flights tf ON s.aircraft_code = tf.aircraft_code
WHERE
tf.aircraft_code = '777-300'
GROUP BY
s.row, tf.fare_conditions
ORDER BY
s.row, tf.fare_conditions;
;
select * from query_cost('SELECT
s.row,
JSON_AGG(s.seat_no ORDER BY s.seat_no) AS seats,
tf.fare_conditions
FROM
seats s
JOIN
ticket_flights tf ON s.aircraft_code = tf.aircraft_code
WHERE
tf.aircraft_code = ''777-300''
GROUP BY
s.row, tf.fare_conditions
ORDER BY
s.row, tf.fare_conditions;
');