Subject | Re: [firebird-support] case - when syntax |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2008-07-27T18:10:11Z |
In your case, I'd use
sum(case when m.dmtipo in ('FI', 'FD') then d.dttotrig else 0 end)
In more complex cases, I'd try something like
sum(case when (m.dmtipo = 'FI' and d.dttotrig > 5) or
(m.dmtipo = 'FD' and d.dttotrig < 0)
then d.dttotrig else 0 end)
In both cases, I'd put m.dmtipo after WHEN (I think having m.dmtipo
before WHEN require a more simple comparison, although it might be due
to me not having explored this possibility carefully enough).
HTH,
Set
Maurizio wrote:
sum(case when m.dmtipo in ('FI', 'FD') then d.dttotrig else 0 end)
In more complex cases, I'd try something like
sum(case when (m.dmtipo = 'FI' and d.dttotrig > 5) or
(m.dmtipo = 'FD' and d.dttotrig < 0)
then d.dttotrig else 0 end)
In both cases, I'd put m.dmtipo after WHEN (I think having m.dmtipo
before WHEN require a more simple comparison, although it might be due
to me not having explored this possibility carefully enough).
HTH,
Set
Maurizio wrote:
> hi ,
> in a select statement i use :
>
> sum(case m.dmtipo when 'NC' then D.dttotrig else 0 end) AS
> "Valore 1 ",
> sum(case m.dmtipo when 'FI' then D.dttotrig else 0 end) AS
> "Valore 2 "
>
> and it does what i want ,
> just i don't know how to add an 'OR' clause : something like
> ...if dmtipo is 'FI' OR 'FD' sum D.dttotrig else 0 end) AS "Valore
> 2 " ...
>
> thanks
> Mauro