Re: Joins with aggregate data - Mailing list pgsql-general

From Paul McGarry
Subject Re: Joins with aggregate data
Date
Msg-id a056b1d405070720371835dbf4@mail.gmail.com
Whole thread Raw
In response to Re: Joins with aggregate data  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Joins with aggregate data
List pgsql-general
Thank you Michael, your suggestion works a charm (though I didn't
bother coalescing the two grp because I think the USING takes care of
that anyway.

Paul

On 7/8/05, Michael Fuhr <mike@fuhr.org> wrote:

> SELECT coalesce(g.grp, b.grp) AS grp,
>        coalesce(g.count, 0) AS countgood,
>        coalesce(g.sum, 0) AS sumgood,
>        coalesce(b.count, 0) AS countbad,
>        coalesce(b.sum, 0) AS sumbad
> FROM
>  (SELECT grp, count(good), sum(good) FROM lefty GROUP BY grp) AS g
> FULL OUTER JOIN
>  (SELECT grp, count(bad), sum(bad) FROM righty GROUP BY grp) AS b USING (grp);

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Joins with aggregate data
Next
From: Tom Lane
Date:
Subject: Re: index bloat