January 21, 2016 at 5:15 am
create table #a (a int, b int)
insert #a values(1,4),(1,4),(1,4),(1,6),(1,6),(1,7),(2,2),(2,3)
select * from #a
ab
14
14
14
16
16
17
22
23
i need o/p
ab c
14 1
14 1
14 1
16 2
16 2
17 3
22 1
23 2
Thanks
January 21, 2016 at 5:21 am
You need the DENSE_RANK function. Give it a try, and post back if you're struggling.
John
January 21, 2016 at 5:29 am
I am not getting by denserank so plz help me
January 21, 2016 at 5:55 am
What do you mean? Please show us what you have tried, and we'll try to show you where you're going wrong.
John
January 21, 2016 at 6:44 am
Quick suggestion
😎
select
A.a
,A.b
,DENSE_RANK() OVER
(
PARTITION BY A.a
ORDER BY A.b
)
from #a A
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply