AnsweredAssumed Answered

SQL query most recent distinct values

Question asked by Ctm Pdm Admin on Jun 29, 2018
Latest reply on Jul 1, 2018 by Ctm Pdm Admin

Hi everyone,


I need to get a list of the 10 most recent distinct values entered in our PDM database for "Approved by Eng" variable.


This is the standard query that gets all distinct values for that variable but I don't know how to sort them based on most recent entries. (I know I can use TOP 10 or LIMIT 10 to truncate the list, but the list has to be sorted based on most recent first)


Select distinct Vv.ValueCache

From VariableValue Vv

Where Vv.VariableID =  (     select variableid

                    from variable

                    where Variablename like 'Approved by Eng')

       And Vv.ValueCache != ''

order by Vv.ValueCache ASC


Does anyone know how to get the most recent entries? I'm SQL-illiterate.