I remember when I was using SQL server we did like like that:
SELECT count(CASE WHEN A THEN 1 END) AS cnt_a, count(CASE WHEN B
THEN 1 END) AS cnt_b FROM tab WHERE C;
I did a little test with pg_bench data, also works in PostgreSQL:
test=# select count(*) from history where tid = 1;
count
---
Steinar H. Gunderson wrote:
> On Wed, Oct 17, 2007 at 02:30:52PM +0200, Stefano Dal Pra wrote:
>> The main goal would be to get multiple results while scanning the
>> table[s] once only
>> thus getting results in a faster way.
>
> In 8.3, Postgres will do this for you itself -- if you already hav
On 10/17/07, Heikki Linnakangas <[EMAIL PROTECTED]> wrote:
> Stefano Dal Pra wrote:
> > suppose you have a large table tab and two (or more) queryes like this:
> >
> > SELECT count(*),A FROM tab WHERE C GROUP BY A;
> > SELECT count(*),B FROM tab WHERE C GROUP BY B;
> >
> > is there any way to get b
On Wed, Oct 17, 2007 at 02:30:52PM +0200, Stefano Dal Pra wrote:
> The main goal would be to get multiple results while scanning the
> table[s] once only
> thus getting results in a faster way.
In 8.3, Postgres will do this for you itself -- if you already have a
sequential scan running against a
Stefano Dal Pra wrote:
> suppose you have a large table tab and two (or more) queryes like this:
>
> SELECT count(*),A FROM tab WHERE C GROUP BY A;
> SELECT count(*),B FROM tab WHERE C GROUP BY B;
>
> is there any way to get both results in a single query,
> eventually through stored procedure?
>
Hi everybody,
suppose you have a large table tab and two (or more) queryes like this:
SELECT count(*),A FROM tab WHERE C GROUP BY A;
SELECT count(*),B FROM tab WHERE C GROUP BY B;
is there any way to get both results in a single query,
eventually through stored procedure?
The retrieved [count(*)