🙏 We need your help! SQLtest.online lives on donations. Donate any amount and ads turn off for your account. Donate now →
SQL code copied to buffer
Task 37:

Flights per Aircraft Model, Including Idle Ones

PostgreSQL
The fleet manager wants to know how many flights each aircraft model has in the schedule, including the models that have no flights at all. Count the flights from the flights table for every model of the aircrafts table. Write the query starting FROM flights and use RIGHT JOIN.
Output the columns model and flights_count (0 for a model without flights), sorted by flights_count from the largest, then by model.
Expected result Columns: 2 · Rows: 9
model flights_count

Sample rows open after wrong checks: 0 of 2

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

The query result will appear here. Ctrl+Enter - Run query