Search Postgresql Archives

Re: Joins with aggregate data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx> 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);

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux