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

Asked

Viewed 44 times

1

I want to select the last 10 inserts of a table and among these 10, return the lowest value. It is 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

1 answer

4


Being direct, it is possible to do this for example using a subquerie.

 SELECT min(id_relevo) FROM 
(SELECT id_relevo FROM relevo ORDER BY id_relevo DESC LIMIT 10) as minimo
  • That’s exactly what it is. Thank you so much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.