Subject Re: [ib-support] Sum, Union and Count
Author Luis
The problem is when i use a "regular" sql
select count(*) as total from clients
where (clientes.id=10) OR (clientes.id=11)

interbase take too long.
So i change the query to speed up.
This query it�s only an example, its not the original.
Here is the original:
Select Count(*) Total From Cliente C,Cliente_Mailing CM ,Mailing_Campanha MC
Where C.id_cliente=CM.id_cliente and CM.id_mailing=MC.id_mailing and
MC.id_campanha in(8,20)

This is a very slow query. I had same problems with other querys (wich didnt
need sum)
where Union solve the problem.



""Wilson, Fred"" <fred.wilson@...> escreveu na mensagem
news:E9E4431A916AD21191FD00104B986AEFC23EFD@......
> Oppps, I may have mis-read your intent. If you want the sum of the number
of
> rows, then the below is the correct way. If you want the sum of the
columns
> called "Total", then my original post will do it.
>
> Best regards,
> Fred Wilson
> SE, Bell & Howell
> fred.wilson@...
>
>
>
> -----Original Message-----
> From: Thomas Steinmaurer [mailto:ts@...]
> Sent: Thursday, August 08, 2002 1:01 PM
> To: ib-support@yahoogroups.com
> Subject: RE: [ib-support] Sum, Union and Count
>
>
> select count(*) as total from clients
> where (clientes.id=10) OR (clientes.id=11)
>
> HTH,
> Thomas Steinmaurer
> IB LogManager 2.0 - The Logging/Auditing Tool for InterBase and Firebird
> http://www.iblogmanager.com
>
> > -----Original Message-----
> > From: news@... [mailto:news@...]On Behalf Of Luis
> > Sent: Thursday, August 08, 2002 9:59 PM
> > To: ib-support@yahoogroups.com
> > Subject: [ib-support] Sum, Union and Count
> >
> >
> > How to do this:
> >
> > Select count(*) Total from clients where clientes.id=10
> > Union
> > Select count(*) Total from clients where clientes.id=11
> >
> > It will return
> >
> > Total
> > -----
> > 300
> > 200
> >
> > Want to return
> > Total
> > -----
> > 500
> >
> > Thanks
> >
> >
> >
> >
> >
> >
> > To unsubscribe from this group, send an email to:
> > ib-support-unsubscribe@egroups.com
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
> >
>
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>