Thursday, 26 May 2016

How to select specific record from last or first

How to select specific record from last or first:

Select col1,col2,col3 from(selectcol1,col2,col3, row_number() over(order by col4,col5 desc) RN)
Where RN=2;

Note: to select second record from last