jeudi 10 décembre 2015

Get all rows containing the two highest values of a column

The example table looks like this:

 last_update | notes
-------------+--------------------
 1449619200  | not that important
 1449619200  | rather useless
 1449705600  | interesting
 1449792000  | very important
 1449792000  | very useful

Now I would like to have an SQLite command that outputs all rows with the two most recent update timestamps (i.e. 1449705600 and 1449792000), so that the output table looks like this:

 last_update | notes
-------------+--------------------
 1449705600  | interesting
 1449792000  | very important
 1449792000  | very useful

What should the command look like?

Aucun commentaire:

Enregistrer un commentaire