Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

I am not able to get exact output with all ranking functions

$
0
0

create table employeedetails(id int, name varchar(20),gender varchar(10),salary int ,city varchar(10))
insert into employeedetails values (1,'jitendra','male',1000,'hyderabad'),(2,'shubham','male',10000,'pune'),
(3,'ajith','male',5000,'banglore'),(4,'jyothi','female',1000,'pune'),(5,'swathi','female',5000,'banglore'),
(6,'rajesh','male',6000,'pune'),(7,'anushka','male',6000,'banglore'),(8,'john','male',9000,'hyderabad'),
(9,'rohit','male',1000,'pune'),(10,'madhuri','female',9000,'pune')
select * from employeedetails

--ranking function
--row number 
select name,id,ROW_NUMBER() over(order by id desc) as row from employee
select name,salary,  RANK() over (order by id desc) as row from employee
select name,salary ,DENSE_RANK() over (order by id asc) as row from employee
select name,salary, NTILE(4) over (order by id asc ) as row from employee



jitendra


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>