DQL Select every rows having one column's MAX value
Working with Symfony 2 and Doctrine, I'm searching for a way to select every rows having the max value in a specific column. Right now, I'm doing it in two queries: One to get the max value of the column in the table Then I select rows having this value. I'm sure this can be done with one query. Searching, I have found this answer in a thread , that seems to be what I am searching for, but in SQL. So according to the answer's first solution, the query I'm trying to build would be something like that: select yt.id, yt.rev, yt.contents from YourTable yt inner join( select id, max(rev) rev from