MySQL Forums
Forum List  »  General

Re: mysql Group by
Posted by: Magnus Olsson
Date: February 03, 2005 08:17AM

Hi!
To me your SQL-query is not valid. Each item in the select list must be either a column in the group by list or a set function. E.g you want one row and the set-function (MAX) will select one value, but timestamp have different values so the DBMS don't know which value to use.

I don't understand why MySQL lets such a query through. It ought to reply with the same kind of error message you get when you execute the same query but without the group by:

"Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause "

To your query...
I think you can use a correlated subquery:

select port, bytes, timestamp
from test t
where bytes = (select max(bytes) from test where input_interface = t.input_interface);

Options: ReplyQuote


Subject
Written By
Posted
December 13, 2004 03:13AM
Re: mysql Group by
February 03, 2005 08:17AM


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.