Учебное пособие Санкт-Петербург «бхв-петербург»


CREATE MATERIALIZED VIEW routes AS



Pdf көрінісі
бет149/256
Дата18.11.2022
өлшемі1.88 Mb.
#465124
түріУчебное пособие
1   ...   145   146   147   148   149   150   151   152   ...   256
sql osnovi yazika

CREATE MATERIALIZED VIEW routes AS
WITH f3 AS
(
SELECT f2.flight_no,
f2.departure_airport,
f2.arrival_airport,
f2.aircraft_code,
f2.duration,
array_agg( f2.days_of_week ) AS days_of_week
FROM
(
SELECT f1.flight_no,
f1.departure_airport,
f1.arrival_airport,
f1.aircraft_code,
f1.duration,
f1.days_of_week
FROM
(
SELECT flights.flight_no,
flights.departure_airport,
flights.arrival_airport,
flights.aircraft_code,
( flights.scheduled_arrival -
flights.scheduled_departure
) AS duration,
( to_char( flights.scheduled_departure,
'ID'::text
)
)::integer AS days_of_week
FROM flights
) f1
GROUP BY f1.flight_no, f1.departure_airport,
f1.arrival_airport, f1.aircraft_code,
f1.duration, f1.days_of_week
ORDER BY f1.flight_no, f1.departure_airport,
f1.arrival_airport, f1.aircraft_code,
f1.duration, f1.days_of_week
) f2
GROUP BY f2.flight_no, f2.departure_airport,
f2.arrival_airport, f2.aircraft_code,
f2.duration
)
190


6.4. Подзапросы
SELECT f3.flight_no,
f3.departure_airport,
dep.airport_name AS departure_airport_name,
dep.city AS departure_city,
f3.arrival_airport,
arr.airport_name AS arrival_airport_name,
arr.city AS arrival_city,
f3.aircraft_code,
f3.duration,
f3.days_of_week
FROM f3,
airports dep,


Достарыңызбен бөлісу:
1   ...   145   146   147   148   149   150   151   152   ...   256




©dereksiz.org 2024
әкімшілігінің қараңыз

    Басты бет