Why is this part of the code needed?

<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.>

<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.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

In this code I am not understanding why the text that is surrounded by “**” is needed. Why are we calling the table f? Then why are we saying “Where carrier = f.carrier”? All this code occurs in the same table so I don’t understand the need for it. It is basically saying this column is equal to the same column, right?



SELECT id
FROM flights **AS f**
WHERE distance > (
 SELECT AVG(distance)
 FROM flights
 **WHERE carrier = f.carrier)**;

1 Like

In objective terms as I read it, f is a member of flights. f.carrier would then be that column in the flights table corresponding to row f It would imply an interative processs.

1 Like

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