RANK in Teradata

The Ranking function (RANK) permits a column to be evaluated and compared, either based on high or low order, against all other rows to create the output set. The order will be sorted by default in descending sequence of the ranking column, which correlates to descending rank.

Example:
NAMESUB1SUB2SUB3
Ria455487
Robert454467
Joel854067
Roshan459467
Joldrine454497


SELECT
NAME
,SUM(SUB1 + SUB2 + SUB3) AS TOTAL_MARKS
,RANK() OVER (ORDER BY TOTAL_MARKS DESC ) AS STUDENT_RANK
FROM STUDENT
GROUP BY 1;


NAMETOTAL_MARKSSTUDENT_RANK
Roshan2061
Joel1922
Joldrine1863
Ria1863
Robert1565