SQL Analytical Function

select * from employee

1.compute:

select * from employee order by id compute min(start_date) ,max(start_date)

 

2. Dense_rank ():

SELECT ID,eName,DENSE_RANK() Over (ORDER BY city) As rank FROM Employee ORDER BY city

 

3. Ntile:

 SELECT eName, NTILE(5) OVER(ORDER BY Salary DESC) AS 'NTILE'  FROM Employee

 

4. Rank:

SELECT ID,eName,RANK() Over (ORDER BY eName) As Rank  FROM Employee ORDER BY eName

 

5. Row_number ():

SELECT eName, ROW_NUMBER() OVER(PARTITION BY Region ORDER BY Salary DESC) AS 'RowNumber'  FROM Employee

 

6. Stdev:

select STDEV(salary) from employee

 

7.WITH ROLLUP:

SELECT City, Region, SUM(Salary) FROM Employee  GROUP BY City, Region  WITH ROLLUP