I have a few simliar tables. I need to select them through *.
I would like to get a list of the rows where revnr is the highest one within each docid.
My problem here is that I don’t know how to get the local max(revnr) for each docid.
I am using MySQL but I’d prefer a general sql solution.
Thanks!
You can get the latest value of
revnrfor eachdocIDin a subquery then the result of that will then join to the table itself.for better performance, add an
INDEXon both columns:docIDandrevnr