Grouping with case statement


#1

Hi everyone, I have so much difficulty trying to understand this code. I am stuck at part 2
I don't know what to fill in and don't understand what it means for order by 2 desc, and how to get denominator and numerator. Thank you so much guys.

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 case name from order items)* 100,2) as pct

from order_items
group by 1
order by 2 desc;


#2

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