Re: count() for a select statement?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: count() for a select statement?
Date: 2002-10-01 18:08:21
Message-ID: 20021001110711.D95989-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 2 Oct 2002, Jean-Christian Imbeault wrote:

> Is there an efficient way to get a count of the number of rows returned
> by this kind of query?
>
> select id from products where name ILIKE 'TNT' UNION select id from
> products where name ILIKE 'ATOM' UNION select id from products where
> name ILIKE 'BOB'

Probably "select count(*) from (select id from ... ) as t"
should work.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message roco 2002-10-01 18:08:52 Fwd: Fwd: FATAL 1: Database dialup does not exist in pg_database
Previous Message Alvaro Herrera 2002-10-01 18:04:12 Re: cluster replication with intermezzo