I'm trying to do the following sql in firebird.
select distinct tb_proostarefas.*,
(case
WHEN (tb_proostarefas.dt_prev is null and tb_proostarefas.dt_vencimento < date) then 1
When (tb_proostarefas.dt_prev is not null and tb_proostarefas.dt_prev < date) then 2
When (tb_proostarefas.dt_prev is not null and tb_proostarefas.dt_prev >= date) then 3
else 3 end) AS 'STATUS'
from tb_proostarefas
order by tb_proostarefas.gut desc, tb_proostarefas.dt_vencimento
I have the following error:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 3, column 83.
).
How can I resolve?