Skip to content
Advertisement

Subquery with WHERE clause => Column does not exist

I try to get the top 3 length per film for each actor. My query looks my this.

So it looks like without the where clause

WHERE fullname = 'Alan Grant' works perfectly. With f_rank I get the following error:

What am I doing wrong here? I´m totally confused.

Advertisement

Answer

You can’t use a column alias defined in the select. But, it doesn’t make sense to do the ranking on the name of the actor when you can do it on the id. If that meets your needs, just move the logic to the subquery:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement