The example states that we want to order flights by giving them a sequence number based on time, by carrier.
The example syntax is:
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;
My question is - why do we want f.id to be less than flights.id? Why not equal to? If I change it to
WHERE f.id = flights.id
the flight_sequence_number is identical between all observations. Why is this? I can't wrap my head around why f.id needs to be less than flights.id. Thanks in advance for any help