Conditional Functions error

I want to run a query to check for ages, and label each age based on certian condition

i tested the following

select age,
CASE
when age > 18 then “adult”
end
from StarGate.“Titanic_Folder”.“Titanic_frame”

and i am getting this error

Column ‘adult’ not found in any table

any help please

Try following

select age,
CASE
when age > 18 
then 'adult'
end AS category
from StarGate.“Titanic_Folder”.“Titanic_frame”

Essentially - single quote, not double

1 Like

Just adding to yufeldman’s answer, in Dremio, double quote is used for quoted identifiers (i.e. column names, table names). Single quote is used for string literals.

1 Like

Excellent, it works.

one more question, i had to write this SQL statement, is there any way to build it using fictions or another feature?

Thanks

Today using CASE statements is probably the best way. In a future release we want to make this easier to construct through the UX and through APIs.

If the conversions are equality based rather than range based, then a lookup table can work great.

Kelly