Detailed explanation of the code

Code Academy really has to do a better job with explaining examples, step by step. This is NOT helpful for beginners.

1 Like

thanks a lot for your explanation, I was stuck with “f.id < flights.id”, I didn’t understand why we have to compare them.
this course should be improved a bit of explanation

Add an ORDER BY clause to the end of your query – it may make it easier to understand what’s going on when looking at the output table. For the initial query that selects ‘carrier’ add:

ORDER BY carrier, flight_sequence_number;

Use ‘origin’ instead of ‘carrier’ for the next query.

This will show the flight sequence, in order, for each airport – a much better visualization of the result.

Hello guys,

try this query…this would make more sense for all of you…

SELECT carrier,
       id,
       (SELECT COUNT(*)
       FROM flights f
       WHERE f.id < flights.id
       AND f.carrier=flights.carrier) + 1 AS flight_sequence_number
FROM flights
order by 1,3 desc;

regards.

BP