Correlated Subqueries II #6


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.

AND f.origin=flights.origin

So 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 <
      	AND     f.origin=flights.origin
      ) + 1
      AS flight_sequence_number
FROM flights;

RE: Correlated Subqueries II #6

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