Re: [GENERAL] Joins with aggregate data

2005-07-07 Thread Michael Fuhr
On Fri, Jul 08, 2005 at 01:37:54PM +1000, Paul McGarry wrote: > > 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. Oops, yeah -- I had started with "ON b.grp = g.grp" but changed it to "USING (g

Re: [GENERAL] Joins with aggregate data

2005-07-07 Thread Paul McGarry
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 <[EMAIL PROTECTED]> wrote: > SELECT coalesce(g.grp, b.grp) AS grp, >coalesce(g.count, 0) AS countgood, >

Re: [GENERAL] Joins with aggregate data

2005-07-07 Thread Michael Fuhr
On Fri, Jul 08, 2005 at 11:45:59AM +1000, Paul McGarry wrote: > I basically want a query which will give me: > == > grp | count(good) | sum(good) | count(bad) | sum(bad) > -+-+-++-- >3 | 0 | | 1 | -5.00 >

[GENERAL] Joins with aggregate data

2005-07-07 Thread Paul McGarry
Hi there everyone, I'm having trouble getting the data I want from my tables. Here is a simplified version of my tables: == create table lefty ( day date, good numeric(10,2), grp integer ); insert into lefty values ('2005-06-01',5.00,1); insert into lefty values ('2005-06-02',10.00,1); in