SQL query EPDM to get document revision

How can I query the EPDM database (using SQL) to get a document's latest Revision number? The documents table has "LatestRevisionNo" but this is the file's version number. I'd like to get the revision number that corresponds to the latest version number.

SolidworksSolidworks Pdm enterprise Pdm