Subject Re: [firebird-support] sql query
Author Alexandre Benson Smith
markd_mms wrote:

>sorry about the subject but i'm not quite sure what is that i'm
>asking...
>
>i'm rewriting our internal helpdesk and there's a report that i need
>to produce to show a summary of calls between particular dates, namely
>the date, the number of calls logged on that date and the number of
>calls resolved on that date. so it looks basically like this...
>
>Date Logged Resolved
>----------------------------------------
>21/02/2005 23 22
>...
>
>i know i can select all calls thusly
>
>SELECT COUNT(*), CAST("Date_Time" AS DATE)
>FROM CALLS
>//where date between...just testing all calls atm
>GROUP BY 2
>ORDER BY 2
>
>is there any way of counting the number of resolved calls (theres a
>"Resolved" column for each call record) in the same query?
>
>running firebird 1.5.2.4731
>
>TIA
>
Hi !

I think there is a bunch of ways to solve this, one is this:

select
Date,
sum(Case when Status = '1' then 1 else 0 end),
sum(Case when Status = '2' then 1 else 0 end),
sum(Case when Status = '3' then 1 else 0 end)
from
PedidoVenda
group by
1

got it ?

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br