Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are given the following query, which shows the total sales for each staff member, for movies with either Boring or Lumberjack or New Orleans
You are given the following query, which shows the total sales for each staff member, for movies with either "Boring" or "Lumberjack"
or "New Orleans" in the movie name. Improve the query performance.
SELECT
sstaffid
CONCATsfirstname, slastname AS staffname,
SUMpamount AS totalsales
FROM
staff s
LEFT OUTER JOIN
rental r ON sstaffid rstaffid
LEFT OUTER JOIN
payment p ON rrentalid prentalid
LEFT OUTER JOIN
inventory i ON rinventoryid iinventoryid
LEFT OUTER JOIN
film f ON ifilmid ffilmid
WHERE
ppaymentdate IS NOT NULL
AND fdescription LIKE Boring
AND fdescription LIKE Lumberjack
AND fdescription LIKE New Orleans
GROUP BY
sstaffid
staffname
ORDER BY
totalsales DESC;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started