New error in this query?

Franck Nsungu Lukanda 86 Reputation points
2022-03-18T10:47:20.66+00:00

Hi again,

Here is a query copied from a training video: it worked in the record, but not for me:

select customer.customer_id
, customer.first_name
, customer.last_name
, count (*) as "Count of Rentals"
from film
inner join inventory
on inventory.film_id = film.film_id
inner join rental
on rental.inventory_id = inventory.inventory_id
left join payment
on payment.rental_id = rental.rental_id
and payment.customer_id = customer.customer_id
group by customer.customer_id
, customer.first_name
, customer.last_name
order by 4 desc;

and I get this error message:

LINE 12: and payment.customer_id = customer.customer_id
^
SQL state: 42P01
Character: 337

Can you please help me?

SQL Server Other
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2022-03-18T11:04:31.707+00:00

    Probably a join with customer table is required, because values like customer.customer_id are undefined. Check the tutorial.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.