Add a category column

I have a ‘category’ column, but the error message says “Add a category column.”

It looks like the instructions and the code are correct, but there’s an error parsing the submitted answer.

Did I do something wrong?

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 'tikka-masala'            then 'dinner'
      when 'chicken-parm'            then 'dinner'
      else 'other'
    end as category
from order_items
order by id
limit 100;

case order_item.name

  1. We’ll build our own categories using a case statement. Complete the query below with a case condition of name that lists out each product, and decides its group.

The list is missing one item, a grilled cheese sandwich.

1 Like

Thanks @mtf! That’ll teach me not to type when I can simply copy / paste :slight_smile: I think this does highlight a bug in Codecademy’s parser, though. The problem had nothing to do with the category column.

Typing is better practice, and it demonstrates errors we might be prone to commit, letting us work out our own wrinkles.

I got the same error and i didnt miss grilled cheese:

select *,
case name
when ‘kale-smoothie’ then ‘smoothie’
when ‘banana-smoothie’ then ‘smoothie’
when ‘orange-juice’ then ‘drink’
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;

I still get the error, any help?

Missing the blt sandwich.

thanks @mtf was a stupid mistake

What’s wrong?

select *,
case name
when ‘kale-smoothie’ then
‘smoothie’
when ‘orange-juice’ then
‘drink’
when ‘soda’ then
‘drink’
when ‘blt’ then
‘sandwhich’
when ‘grilled-cheese’ then
‘sandwhich’
when ‘tikka-masala’ then
‘dinner’
when ‘chicken-parm’ then
‘dinner’
else ‘other’
end
as category
from order_items
order by id
limit 100;

1 Like

Missing banana smoothie in the selection.

1 Like

A post was split to a new topic: Category column shows up in the sidebar