Select a list of values and from this list, select the lowest value

1

I want to select the last 10 inserts of a table and among those 10, return the lowest value. Is it possible to do this in a single query?

Selecting the last 10 values:

SELECT id_relevo FROM relevo 
ORDER BY id_relevo DESC
LIMIT 10
    
asked by anonymous 23.09.2018 / 03:30

1 answer

4

Being straightforward, you can do this for example by using a subquery.

 SELECT min(id_relevo) FROM 
(SELECT id_relevo FROM relevo ORDER BY id_relevo DESC LIMIT 10) as minimo
    
23.09.2018 / 04:26