Great solution Igor!

On 13/01/07, Igor Tandetnik <[EMAIL PROTECTED]> wrote:

Lloyd Thomas
<lloydie-t-d/OCxD/[EMAIL PROTECTED]> wrote:
> I wish to create a query where I do a number of counts on the same
> table but
> with different filters.
> ie:
> count(id) as numrows
> count(id) as inrows where direction = 'In'
> count(id) as outrows where direction = 'Out'
>
> Could I do the above in a single query?

select
   count(*) as numrows,
   count(case direction when 'In' then 1 else NULL end) as inrows,
   count(case direction when 'Out' then 1 else NULL end) as outrows
from mytable;


Igor Tandetnik



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]

-----------------------------------------------------------------------------




--
Cesar Rodas
http://www.sf.net/projects/pagerank (The PageRank made easy...)
Mobile Phone: 595 961 974165
Phone: 595 21 645590
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to