Issues when running code on Grouping with Case Statements


#1

I am having trouble with the second exercise on 1.9, Grouping With Case Statements. I edited the provided code to add 'sum(amount_paid)' after the second select statement to get the percentage sales for each category. However, when I hit 'run' the editor just runs forever, or until my browser freezes. What is the problem with my code that's creating this issue?

Here's the link to the exercises: 1.9 I am stuck on the second exercise.


Here's the code just runs until my browser freezes.


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 sum(amount_paid) from order_items) * 100, 2) as pct
from order_items
group by 1
order by 2 desc;


#2

Not sure we need to select all.

SELECT
  CASE name

#3

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