Re: simple? join - Mailing list pgsql-sql

From Christopher Kings-Lynne
Subject Re: simple? join
Date
Msg-id GNELIHDDFBOCMGBFGEFOCEAMCBAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: simple? join  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: simple? join
List pgsql-sql
> So, when and if we get around to implementing this particular SQL99
> feature, what you are suggesting will work.  Right now it doesn't
> (and I'll wager that darn few other SQL implementations support this
> feature as yet, either).

I think MySQL does.  I always found it strange that I had to add columns to
the group by clause in postgres that were functionally dependent on the
"real" grouped variable.

In fact, before I realised that you had to add them to the group by clause,
I just wrapped the functionally dependent fields in a MAX function (or min,
whatever).

ie. SELECT orders.product_id, MAX(product_name), MAX(unit_price) FROM
products NATURAL JOIN orders GROUP BY orders.product_id;

In fact, if one created a 'do nothing' aggregate function, you could avoid
having to add things to the group by clause in a cleaner fashion.

Chris



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: SELECT * FROM xy WHERE name LIKE '%german special char'
Next
From: Tom Lane
Date:
Subject: Re: simple? join