USE Study
GO

-- TOP

SELECT TOP(5) * FROM EMPLOYEE ORDER BY SALARY DESC

SELECT TOP(5) WITH TIES * FROM EMPLOYEE ORDER BY SALARY DESC

SELECT TOP(20) PERCENT * FROM EMPLOYEE ORDER BY SALARY DESC

SELECT TOP(5) * FROM EMPLOYEE ORDER BY SALARY DESC


-- RANK
SELECT ENAME, SALARY, RANK() OVER (ORDER BY SALARY DESC) AS SALRANK FROM EMPLOYEE

SELECT ENAME, SALARY, DENSE_RANK() OVER (ORDER BY SALARY DESC) AS SALDENSERANK FROM EMPLOYEE

SELECT ENAME, SALARY, ROW_NUMBER() OVER (ORDER BY SALARY DESC) AS SALROWRANK FROM EMPLOYEE

SELECT ENAME, SALARY, NTILE(5) OVER (ORDER BY SALARY DESC) AS RANKNTILE FROM EMPLOYEE
