9. Grouping with Case Statements Step 2

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<https://www.codecademy.com/en/courses/sql-analyzing-business-metrics/lessons/advanced-aggregates/exercises/product-grouping?action=resumeBelow this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Keeps displaying this error message, ‘Group by the category.’

<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

```

select
case name
when ‘kale-smoothie’ then ‘smoothie’
when ‘banana-smoothie’ then ‘smoothie’
when ‘orange-juice’ then ‘drink’
when ‘soda’ then ‘drink’
when ‘blt’ then ‘sandwich’
when ‘grilled-cheese’ then ‘sandwich’
when ‘tikka-masala’ then ‘dinner’
when ‘chicken-parm’ then ‘dinner’
else ‘other’
end as category, round(1.0 * sum(amount_paid) / (select amount_paid from order_items) * 100, 2) as pct
from order_items
group by 1
order by 2 desc;

<do not remove the three backticks above>
(select sum(amount_paid) from order_items) * 100, 2) as pct

Either I have this wrong, or you do.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.