in reply to Re^2: (OT) MySQL query to limit and sort
in thread (OT) MySQL query to limit and sort

Apologies:
SELECT id, total FROM some_table WHERE id > (SELECT MAX(id) FROM some_table) - 10 ORDER BY total DESC

Replies are listed 'Best First'.
Re^4: (OT) MySQL query to limit and sort
by rhesa (Vicar) on Feb 03, 2006 at 23:01 UTC
    It's slightly fragile in the face of deletions. Say you have records 140 through 160, delete 150 through 159, then run this query. That will only return record 160, while I would expect (141 .. 149, 160). But that may just be my interpretation of the OP's question asking for a top 10.