There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I’m struggling with how to phrase this, but I think this exercise is an error. That is, I think it wasn’t implemented properly by whoever implemented these exercises.
Using a window function with PARTITION BY , get the total change in gross for each movie up to the current week and display it next to the current week column along with the title , week , and gross columns.
So, specifically, the directions are to get the ‘change in gross’ and display it. But the answer to the challenge is as follows: SELECT title,week,gross, SUM(gross) OVER ( PARTITION BY title ORDER BY week ) AS 'running_total_gross' FROM box_office;
The tip-off here that this is an implementation error is that the directions ask for the change in gross, and yet in the passing code example they use ‘running_total_gross’ as a column name. Additionally, one wouldn’t expect to use the SUM aggregate when trying to calculate the change from week to week. Granted I’m just learning SQL, but upon reading the directions my first instinct was to use LAG. Someone should probably review this one.
I agree with both of the above and reported this as a bug. The assignment and accepted answer don’t match, and the accepted answer is unnecessary as there is already a column for it.
Technically, the assignment should probably be reworded: “total change in gross” would actually just be that week’s gross which is also its own column. I think the intent behind the assignment is to find “change in weekly gross”
Completely agree with above, this question looks like a mistake. The answer they want is the same as the to_date_gross column, but the question suggests we should provide the change in gross each week using LAG function.