MySQL Forums
Forum List  »  General

Re: subquery bug ?
Posted by: Benoit St-Jean
Date: March 11, 2017 02:27PM

You need something like this (btw your results were wrong):

SELECT sb.id, sb.some_type, sb.some_name
FROM subquerybug sb
INNER JOIN
(
SELECT id, MAX(some_type) AS biggest_type
FROM subquerybug
GROUP BY id
) t1
ON (t1.id=sb.id AND sb.some_type=t1.biggest_type);

Also, try not to use reserved/special words (e.g. TYPE) for column names : it will save you from lots of headaches!

Options: ReplyQuote


Subject
Written By
Posted
March 10, 2017 02:01AM
March 10, 2017 12:21PM
March 11, 2017 09:52PM
Re: subquery bug ?
March 11, 2017 02:27PM
March 11, 2017 09:42PM
March 11, 2017 10:02PM
March 13, 2017 10:50PM
March 16, 2017 10:47AM


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.