Quantcast
Viewing all articles
Browse latest Browse all 35

Answer by Dwipam Katariya for How to select the nth row in a SQL database table?

select * from (select * from ordered order by order_id limit 100) x order by x.order_id desc limit 1;

First select top 100 rows by ordering in ascending and then select last row by ordering in descending and limit to 1. However this is a very expensive statement as it access the data twice.


Viewing all articles
Browse latest Browse all 35

Trending Articles