Lesson 6/7


#1

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;

This is the code from the example they gave us, I don't understand what f is, is it just an alias for flights, and if so whats the point of f.id < flights.id, and what is the point of the +1?


#2

I found
https://discuss.codecademy.com/t/correlated-subqueries-ii-understanding-code-logic/38615/6


#3

I'm having trouble with the same thing, i don't understand how to code SQL it is kinda weird


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.