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!
Agree with a comment or answer? Like () to up-vote the contribution!
for the lats several exercises I have written the code, but am given an error. I don’t know what I did wrong, Can’t figure it out, I look at the hint and even after making it look just like the code it doesn’t work, It isn’t until copy a pasting the code from the hint that it compiles,
Very curious! I don’t see where there is an error… What is interesting is the SQL error in bottom right corner… I just ran exact code and had no issue.
I am current;y having the same issue using my code below
SELECT SUM(amount), pay_date
FROM payments
WHERE status = ‘paid’
GROUP BY 2
ORDER BY SUM(amount) DESC;
I thought the same thing myself, but notice that the results of the correct answer are different than the results using HAVING status = 'paid'.
Since WHERE filters rows, you want to use WHERE here because you only want to include rows that have status paid when taking the sum() of the payment values.
If you use HAVING, you’re filtering the GROUP BY results, so I suppose you would be including rows whose status is not paid in the sum calculation, thus giving you different (and consequently incorrect) results.
was wondering why can’t I use having to solve this problem instead of where.
I tried with Having and got the same result however, in the workspace it returns an error.
Any suggestions on this will be really helpful.
Why does the WHERE clause need to be
WHERE status = ‘paid’
instead of WHERE status LIKE ‘paid’?
I figured either should work but the WHERE + LIKE combination was incorrect.