Re: Question About Aggregate Functions

From: Oscar Rodriguez Fonseca <info(at)vraniscci(dot)com>
To: Don Parris <parrisdc(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Question About Aggregate Functions
Date: 2006-09-13 11:21:52
Message-ID: 1158146512.6056.52.camel@vrlap.localvrnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

El mié, 13-09-2006 a las 13:16 +0200, Oscar Rodriguez Fonseca escribió:

> A query (UNTESTED) that should solve your problem may be this one:
>
> SELECT a.count AS "t1fielda",
> b.count AS "t2fielda",
> c.count AS "t2fieldb",
> d.avg AS "t2avgc"
> FROM (SELECT count(*) FROM t1 WHERE fielda = TRUE) AS a
> JOIN (SELECT count(*) FROM t2 WHERE fielda = TRUE) AS b ON TRUE
> JOIN (SELECT count(*) FROM t2 WHERE fieldb = TRUE) AS c ON TRUE
> JOIN (SELECT avg(fieldc) FROM t2) AS d ON TRUE;
>
> I am also a DB novice so this is correct.

Sorry, I was trying to write:

"I am also a DB novice so I HOPE this is correct".

Best regards.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brandon Aiken 2006-09-13 13:00:56 Re: [NOVICE] INSERT does not finish except if it is carried out a
Previous Message Oscar Rodriguez Fonseca 2006-09-13 11:16:42 Re: Question About Aggregate Functions

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2006-09-13 11:40:19 Re: pg_dump password
Previous Message Oscar Rodriguez Fonseca 2006-09-13 11:16:42 Re: Question About Aggregate Functions