Function : RANK with
Groupings
|
||||||||||||||||||||
Teradata Syntax:
We use the following Teradata syntax perform ranking with groups
Following
query gives employee with highest salary with department.
SELECT EMPLOYEEID,DEPARTMENTNO,SALARY,RANK(SALARY) AS RNK
FROM
EMPLOYEE
GROUP BY DEPARTMENTNO
QUALIFY
RNK = 1;
Thus
in Teradata Syntax:
|
||||||||||||||||||||
ANSI syntax:
We can get the same result by making use of ANSI syntax as follows: SELECT EMPLOYEEID,DEPARTMENTNO,SALARY,
RANK() OVER (PARTITION BY
DEPARTMENTNO ORDER BY SALARY DESC) AS RNK
FROM EMPLOYEE
QUALIFY
RNK = 1;
Thus
in ANSI syntax:
|
Pages
▼
No comments:
Post a Comment