[SQL] distinct / group by assistance.

2008-06-28 Thread Gavin 'Beau' Baumanis
Hi Everyone, I am having some issues trying to create the required SQL that will allow me to return the results I am after. I have been trying various incarnations, using group by, sub-queries - albeit to no avail - for the past three hours. Consider the following simple SQL; select a

Re: [SQL] distinct / group by assistance.

2008-06-28 Thread Tom Lane
"Gavin 'Beau' Baumanis" <[EMAIL PROTECTED]> writes: > ... If there a multiple rows of the same id in table1, I get all > (multiple) rows - as you would expect - of course. > What I need however, is only one row returned per instance a.id that > is returned by the above query. You need GROUP B

Re: [SQL] distinct / group by assistance.

2008-06-28 Thread Gavin 'Beau' Baumanis
Hi Tom I am a nut. please find below my correct requirements. select a.foo, b.bar, c.something from table1 a, inner join table2 b on b.id =a.id left outer join table3 on c.id = a.id If there a multiple rows of the same id in table2,(one (a) to many (b) relatio