ziggy ziggy - 6 months ago 24
SQL Question

SQLite Case Statement

All the values in the orders table are there and are integers. I am not sure what I am doing wrong syntax wise. it keeps giving me this error

near "range": syntax error:

select
case
when AMOUNT < 2000 then "low price"
when amount between 3000 and 2000 then "medium price"
else "high price"
end as price range,
count(*)
from orders
group by 1;

Answer

If you want spaces in names then use backticks

as `price range`
Comments