Hi! I cannot understand how the example works:
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;
What is the value of f.id and f.carrier? I am trying to get them by doing this:
SELECT f.id FROM
(SELECT COUNT(*)
FROM flights f);
but it does not work(please explain why)
Also I am confused whether ‘f’ means 499 or ‘f’ means the same as ‘flights’.
Please help:(