Lists from SQL query on latest versions only??

We have setup some lists that get the data directly from SQL, one example is for the variabel Vendor Name. However, it returns values from all versions of files. So if someone has corrected the spelling of a vendors name, thereby creating a new version the list returns both values.

Is there a way to program the SQL list so that it only returns the values from the latest version of files? (I'm brain dead when it comes to SQL!)

Here is thq SQL query we are using which is straight from the example in the Admin Guide.

Select distinct Vv.ValueCache
From VariableValue Vv
Where Vv.VariableID =  (    select variableid
            from variable
            where Variablename like 'Vendor Name') And
      Vv.ValueCache != ''
order by Vv.ValueCache ASC

SolidworksSolidworks Pdm enterprise Pdm