Correlated Subqueries II

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
I’m currently working on Correlated Subqueries II. The exercise seems trivially simple, since the example given is so close to the solution, but I’m not having any luck getting it correct. I get a table without errors that looks like it fulfills all the requirements of the solution, but I get the error message

“Find the origin, flight id, and sequence number.”

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

Code follows:


SELECT origin, id,
	(SELECT COUNT(*)
   FROM flights f
   WHERE f.id < flights.id
   AND f.carrier=flights.carrier)+1
   AS flight_sequence_number
   FROM flights;  


Am I missing something silly, or is this a bug?

We are accessing the origin column, not carrier.

AND f.origin=flights.origin) + 1
3 Likes

Ok, thanks. The problem statement only says to list by origin, not that the sequence numbers should be re-evaluated on a per-origin basis.

2 Likes

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