I'm with slim and davey on this, there is no first and last row.....there are just rows, its up to you how the data is used, you'd need something like a sequence or timestamp colum to order the rows in your SQL