Get Current Rev Levels SQL

Is there a way to query the PDM Database do show me the letter value of all documents that are either dwg or slddrw. Or I should be asking has someone done something like this before?

I need to compare the revision levels of all drawing files to the revision level that our ERP program says it should be at and outside of opening and comparing each data card revision varible I was hopeing to just export them from PDM and compare the results from our ERP export.

What I am looking to get is

dbo.documents  Filename where filetype = 3 or 49 and then get the revision Letter for those documents

SolidworksSolidworks Pdm enterprise Pdm