Re: [SQL] Aggregating both tables in a join?

2007-01-11 Thread Aaron Bono
On 1/11/07, Steve Sabljak <[EMAIL PROTECTED]> wrote: select cf.flight_id, tl1.num_legs, cf.cmp_flight_id, tl2.num_legscmp_num_legs from cmp_flight cf join (select fl1.flight_id fid1, count(*) num_legs from flight_leg fl1 group by fl1.flight_id) tl1 on fid1 = cf.flight_id join (

[SQL] Aggregating both tables in a join?

2007-01-11 Thread Steve Sabljak
Hi, I've got a table which models the relationship between flights and legs, which is defined like this:- create table flight_leg ( flight_id integer references flight(id), leg_id integer references leg(id) ); One leg may be part of many flights and one flight may be made up of 1 or more