Subject | RE: [firebird-support] How to use case and where together |
---|---|
Author | Leyne, Sean |
Post date | 2006-06-27T23:40:06Z |
Guido,
This is not yet supported -- it has been requested, though.
select
acdate,
accompleted,
case
when ((acdate<current_date) and (accompleted=0)) then 1
else 0
end as acoverdue_new
from activities
where
(case
when ((acdate<current_date) and (accompleted=0)) then 1
else 0
end) <> 0
Sean
> I want to run the following queryYou are trying to use a column 'alias' (acoverdue) in a where clause.
>
> select acdate,accompleted,
> case
> when ((acdate<current_date) and (accompleted=0)) then 1
> else 0
> end as acoverdue_new
> from activities
> where acoverdue_new<>0
>
> and get the error that the column acoverdue is unknown.
This is not yet supported -- it has been requested, though.
> Is it possible to use the result of a case statement in the whereclause
> and if yes, how can I do it?Very simple.
select
acdate,
accompleted,
case
when ((acdate<current_date) and (accompleted=0)) then 1
else 0
end as acoverdue_new
from activities
where
(case
when ((acdate<current_date) and (accompleted=0)) then 1
else 0
end) <> 0
Sean