RE: Correlated Subqueries II #6


#1

https://www.codecademy.com/courses/sql-table-transformation/lessons/subqueries/exercises/correlated-ii?action=lesson_resume

I was hoping to explain to @jordanw9000 (Post @ Correlated Subqueries II #6) (as well as myself) “How are we able to find an id column less than another id column from the same table?”

If you, or other seekers are still questioning the logic, I figure that the alias f, creates a temporary table that is a copy of the flights table. In this way, it can perform the operations between the original and copy. In this case, the query counts the number of flight.id integers that are less than f.id, then add 1, so if there are none less than it, leaving only itself, then it gets Flight Sequence Number “1”.

This is totally open for discussion, so if anyone else has information to add, feel free to do so.

Moreover, I know I was stuck for a while after the instructions said, “For instance, assuming flight_id increments with each additional flight…”, I was looking at the table schemas searching for it… but I guess it was supposed to be flight.id


#2

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