How to get the n-th row in a SQL table ..in 4 different ways! Simple, clear and with example!
Hi guys, After the deep previous post about the SQL statistic today we will talk about a more more easy topic. Have you ever needed to extract from a table the second row, or the third or the n-th row? This post is for you! Extract ..Get..Select... the n-th row in a table We can solve this task in more than one way. To follow my example you can simply execute the following command that create and fill the Ord table with some data Create Table Ord (Id int identity (1,1) primary key , Code varchar (10)) Insert into Ord (Code) values ( 'A' ),( 'B' ),( 'C' ),( 'D' ),( 'E' ),( 'F' ),( 'G' ),( 'H' ),( 'I' ) This is our table: The first way I seen many times is using a derivate table . Yes, you can solte the request by split the problem in two parts. In the first part you can get the first n-th rows. This will be the derivate table. Then you can get first row of this derivate table orde...