MySQL Forums
Forum List  »  General

5.5->5.7 problem. group by & order by
Posted by: Seungwon Park
Date: July 03, 2016 07:12AM

select * from (
select * from table_name order by col1, col2 desc
) as my_table_tmp group by col1;


I am not a specialist in mysql. I wandered to ask this question but, It was not easy to get the answer. Can anyone help me, I think this forum is filled with specialists so I hope good result here..
I want to execute above query. If column 1 is identical then I want to choose the one with biggest value in column 2. Upper query worked fine with mysql 5.5.
But In 5.7(now I am using), this query always gets me the least of column 2 with no regard to desc or asc option.. I changed desc to asc and the result was chosen.

How can I do "If column 1 is identical then I want to choose the one with biggest value in column 2."

cf)I made the only_full_group_by off.

Options: ReplyQuote


Subject
Written By
Posted
5.5->5.7 problem. group by & order by
July 03, 2016 07:12AM


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.