Премиум
Войти
WITH name_cte [(column_1 [, column_2 ] …)] AS (subquery)
WITH Aeroflot_trips AS (
SELECT TRIP.*
FROM Company
INNER JOIN Trip ON Trip.company = Company.id
WHERE name = "Aeroflot"
)
SELECT plane, COUNT(plane) AS amount
FROM Aeroflot_trips
GROUP BY plane;