MySQL Forums
Forum List  »  Newbie

Re: Problems with GROUP BY ?
Posted by: Chris Stubben
Date: April 07, 2005 10:34AM

Hi,

Mysql has a nice non-standard SQL feature called GROUP by with hidden fields.

http://dev.mysql.com/doc/mysql/en/group-by-hidden-fields.html

If you were to run your query in any other RDBMS, it would complain that a.amount and b.price are not included in the GROUP BY statement. Mysql treats them as 'hidden' fields and includes them in the output. However, if multiple values exist for the a.product_id, b.currency_id, and max( b.active_date ) combination, you will get unpredictable results.

Generally you should include all columns in the GROUP BY clause that do not include a summary function (max(), min(), sum(), count(). etc.)

GROUP BY a.product_id, a.amount_id, b.currency_id, b.price


Chris

Options: ReplyQuote


Subject
Written By
Posted
April 07, 2005 09:30AM
April 07, 2005 10:00AM
Re: Problems with GROUP BY ?
April 07, 2005 10:34AM
April 08, 2005 01:10AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.