0

I have created the following select query to display data based on if then else using CASE-WHEN-THEN

select id,name,
    case
     when rating between 4.0 and 5 then "very good"
     when rating between 3.0 and 3.5 the "good"
    else "Good Resort"
    end as comment
from resort
order by id;

when executed it gives this

error

ORA-00904: "Good Resort": invalid identifier

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55

1 Answers1

5

Use single quotes. Double quotes get interpreted as a field:

select id,name,
    case
     when rating between 4.0 and 5 then 'very good'
     when rating between 3.0 and 3.5 then 'good'
    else 'Good Resort'
    end as comment
from resort
order by id;
kfinity
  • 8,581
  • 1
  • 13
  • 20
zip
  • 3,938
  • 2
  • 11
  • 19