Pregunta

I seem to be getting a syntax error on the case line between phone_number and LIKE. SQLdeveloper say it is expecting a . ( or | with the following statement;

SELECT  phone_number,
    last_name,
    CASE phone_number WHEN phone_number LIKE '590%' THEN 'blagh'
                      ELSE "unknown" END "area code"

from employees;

Bearing in mind that he phone_numbers column is a char column and not a number column. I need to draw out another 5 area codes from the phone_number section using a case statement (for a test) else the rest are listed as unknown. I attempted to use SUBSTR function but that did not seem to work either. Is it not possible to use the LIKE comparison operator within a case statement? Thanks in advance

¿Fue útil?

Solución

Try this:

SELECT  phone_number,
last_name,
CASE WHEN TO_CHAR(phone_number) LIKE '590%' THEN 'blagh'
                  ELSE "unknown" END "area code"

from employees;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top