Rohit

Rohit

  • NA
  • 238
  • 32.9k

SQL-query rank function

Nov 9 2016 6:45 AM
 
 bwlow is my query 
 
with A as (select *,RANK() over(partition by ClientID order by ContactDateTime desc) as RNK from vwREClient)select * from A
where callForActivityID=1 and ContactDirectionID > 0
 i am getting below out put from where these 13 and 20 come i didnt understand please help me
 
 
RNK
1
2
1
1
13
20
1
1
5
6
1
2
3
2
1
12
1
8
2
2
5
7
1
4
10
3
4
1
5
6
2
1
4
2
9
18
10
11
12
1
1
2
8
7
2
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
7
1
1
1
1
5
3
4
2
2
4
2
11
12
13
12
5
2
13
14
2
2
4
7
7
3
4
5
1
6
9
10
3
1
8
1
3
1
1
4
1
4
1
13
14
1
2
3
3
1
3
2
14
15
5
3
5
1
6
8
1
5
5
4
1
1
1
2
4
2
6
7
9
2
3
1
2
3
4
1
6
7
16
2
15
7
22
3
7
8
13
1
2
17
3
3
1
14
13
1
2
14
3
8
2
4
5
6
9
10
3
8
12
13
1
2
9
9
10
2
5
12
3
4
5
6
5
8
1
18
1
5
6
7
3
13
14
4
4
6
7
5
6
7
8
1
1
1
2
3
1
1
9
7
 

Answers (1)