Selecting records using QUALIFY in Teradata

Using Qualify, you can select particular records from a table.

Consider the following table student,
idname
1r
2s
3t
4u
5v


If you want to select the second record from the bottom then,
SELECT * FROM student QUALIFY RANK(id) =2;


Then the output will be,
idname
4u


If you want to select the second record from the top most then,
SELECT * FROM student QUALIFY RANK(id ASC) =2;


Then the output will be,
idname
2s