I am facing a difficult problem. I store all the versions of all the documents in a table. Each document has a unique ID, and the version is stored as an integer, which increases a new version every time.
I need a query which will only select the latest version of each document from the database, using the works by the group, it appears that the versions are not included in the database in the order of the version (I.e. takes the maximum ROWID which will not always be the latest version).
Note, the latest version of each document will most likely be a different number (i.e. Document A is in version 3, and Document B is at version 6).
I am at the end of my mind, do anyone know how to do this (select all the documents, but only return one record for each document_ id, and the highest return in the record Should be version number)?
Assume that the table is called a docs
select code t. * From Docs T Inner Join (Choose ID, View from Docs Group according to Max (version) ID) as T2 where t2.id = t.id and t2.ver = t.version
Comments
Post a Comment