P
P
pavuuuk2020-03-10 19:53:43
PostgreSQL
pavuuuk, 2020-03-10 19:53:43

How to count the number of canceled flights from led airport that both departed and arrived on Thursday?

There are two tables, routes and flights. It is necessary to count the number of canceled flights from Pulkovo Airport (LED), both departure and arrival of which were scheduled for Thursday.

Routes
5e67c4b0611a8456770937.png

Flights
5e67c4b727bb8218232239.png

This is a demo base from the postgres site: https://postgrespro.ru/education/demodb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2020-03-11
@pavuuuk

Apparently:

SELECT COUNT(*) FROM Flights
WHERE status='Cancelled' AND ((departure_airport='LED' AND EXTRACT(DOW FROM TIMESTAMP sheduled_departure)=4)
OR (arrival_airport='LED' AND EXTRACT(DOW FROM TIMESTAMP sheduled_arrival)=4))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question