Disclaimer: Squeaky clean newb here. I believe I may be over thinking this. The code is fine, I got the answer from another post but I still want to know why and/or what is going on.
WHERE f.id < flights.id
So f.id is calling f ("flights" table) and the column "id" from it, right? But then we're trying to find where that is less than "flights" table and.. column id (..again??)
How are we able to find an id column less than another id column from the same table?
Same question for the f.origin line.
SELECT origin, id, ( SELECT COUNT(*) FROM flights f WHERE f.id < flights.id AND f.origin=flights.origin ) + 1 AS flight_sequence_number FROM flights;