Advanced Aggregates. Grouping with Case Statements


#1

I need help please

select *,
/**/
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
from order_items
order by id
limit 100;


#2

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
from order_items
order by id
limit 100;


#3

That's exactly what i've and it won't passed.


#4

Please show your error message.


#5

This is happening to me too. I've entered the code:
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
from order_items
order by id
limit 100;

and it keeps saying it is incorrect. The error message says 'add category' when i have! The query results look correct, too. Can anyone help?


#6

The error msg says 'add a category column'. Thanks.


#7

It passed sorry i didn't got back to you.