Sorry, your browser is not supported
To have the best experience using Skillshare, we recommend that you use one of these supported browsers.

6

--

Challenge Questions (1 of 7 so far)

The “challenge questions”

Queries that answer very simple and important questions, but are challenging to write.

 

  1. Who were our best 10 customers in the last three months of 2012?

 

SELECT customer_name, SUM(movie_price) AS rev FROM movie_data AS md

INNER JOIN order_data AS od ON md.movie_id = od.movie_id

INNER JOIN customer_data AS cd ON cd.customer_id = od.customer_id

WHERE MONTH(datetime) >= 10 AND YEAR(datetime) = 2012

GROUP BY customer_name

ORDER BY rev DESC

LIMIT 10

Comments

Please sign in or sign up to comment.