Ashwani Kumar
Ashwani Kumar

Reputation: 21

Dense_Rank function not work

I have a below query :

select id, firstname,LastName,Company, dense_rank() over (partition by company order by id ) 

from UserAdditionalData 

where Company is not null

Here is the result that I am getting: http://prntscr.com/a9d454. Dense_Rank function is not working,please help me in this.

Upvotes: 1

Views: 1223

Answers (1)

MT0
MT0

Reputation: 168041

What I want is that partition by company.But ,If the company is same then last column value remains the same for same company.

That is not partitioning by company - in fact it requires no partitioning at all.

What you want is:

SELECT id,
       firstname,
       LastName,
       Company,
       dense_rank() over ( order by company ) AS Company_Rank
FROM   UserAdditionalData 
WHERE  Company IS NOT NULL

Upvotes: 3

Related Questions