This is a clarification on this post:
SQL select only rows with max value on a column
In the accepted answer, the nested query is the one used for the max computation and the outer query joins to that. I tried to reverse the order but ran into a syntax error.
Query:
(SELECT id, MAX(rev) mrev
FROM docs
GROUP BY id) b
join (select id, rev, content from docs) d
on b.id = d.id and d.rev = b.rev
There error I run into is this:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b join (select id, rev, content from docs) d on b.id = d.id and d.rev = b.rev' at line 3
Does the order matter here?
Here is the link: http://sqlfiddle.com/#!9/a6c585/64570