Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: GROUP BY & ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 3668 of 3782
Post > Topic >>

Re: GROUP BY & column not in select list

by =?ISO-8859-1?Q?Arne_Vajh=F8j?= <arne@[EMAIL PROTECTED] > Mar 3, 2008 at 10:29 PM

anssiman@[EMAIL PROTECTED]
 wrote:
> is there any way to cheat group by -statement or make the query in
> other way? I mean that query:
> 
> SELECT userid, name, MAX(age) FROM users GROUP BY name;
> 
> produces list of the oldest users grouped by the name, but the
> userid is also available (this way it is not valid at all).
> 
> Table contains rows:
> ...
> 12 | Jack | 18
> 13 | Jim   | 22
> 14 | Jack | 56
> ...
> 
> and the query above should return:
> 13 | Jim   | 22
> 14 | Jack | 56
> 
> Keen to know if there is solution!

MySQL actually allows that syntax.

It pick a random value for the non-aggregated and non-groupedby
column.

I find it difficult to see why anyone would want that feature.

It is forbidden in standard SQL.

Arne
 




 6 Posts in Topic:
GROUP BY & column not in select list
anssiman@[EMAIL PROTECTED  2008-03-03 06:25:21 
Re: GROUP BY & column not in select list
Lew <lew@[EMAIL PROTEC  2008-03-03 09:59:32 
Re: GROUP BY & column not in select list
Lew <lew@[EMAIL PROTEC  2008-03-03 10:01:58 
Re: GROUP BY & column not in select list
Lew <lew@[EMAIL PROTEC  2008-03-03 10:31:15 
Re: GROUP BY & column not in select list
=?ISO-8859-1?Q?Arne_Vajh=  2008-03-03 22:29:28 
Re: GROUP BY & column not in select list
anssiman@[EMAIL PROTECTED  2008-03-03 23:52:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 5 15:43:00 CDT 2008.