Rohit

Rohit

  • 1.8k
  • 236
  • 22.4k

SQL urgent need help

Nov 9 2016 8:04 AM
this is my query 
 
with A as (select ClientID,CommunicationLogID,Fullname ,ContactDayID ,callForActivityID,ContactDirectionID,ContactDateTime,RANK() over(partition by ClientID order by ContactDateTime desc) as RNK from vwREClientCommunication)select * from A
where ContactDayID >=1887 and ContactDayID <=1887 And callForActivityID=1 and ContactDirectionID > 0
 
below is a table that return by above query
 
please focus on last coloumn  "RNK" which is i am getting wrong 
 
please help me where i am getting wrong after 1,2
 it should again started 1 but it getting 13,20 and something else 
 
 
 
 
ClientID CommunicationLogID ContactDayID callForActivityID ContactDirectionID ContactDateTime RNK
485 259837 1887 1 2 55:00.0 1
9001 259767 1887 1 2 39:59.0 2
9424 259727 1887 1 2 46:22.0 1
13736 259814 1887 1 2 10:25.0 1
22784 259875 1887 1 2 14:54.0 13
23996 259785 1887 1 2 54:54.0 20
24399 259833 1887 1 1 45:15.0 1
24449 259826 1887 1 2 32:29.0 1
28048 259860 1887 1 2 45:29.0 5
28048 259857 1887 1 2 43:02.0 6
32807 259746 1887 1 2 36:04.0 1
32807 259729 1887 1 2 54:24.0 2
32807 259716 1887 1 2 15:07.0 3
34541 259756 1887 1 2 10:13.0 2
36326 259791 1887 1 2 13:39.0 1
37530 259757 1887 1 1 12:20.0 12
37584 259771 1887 1 1 12:35.0 1
40028 259749 1887 1 2 43:35.0 8
41062 259824 1887 1 2 25:43.0 2
41551 259858 1887 1 2 43:26.0 2
42783 259907 1887 1 2 24:33.0 5
43161 259914 1887 1 2 43:53.0 7
 
 

Answers (1)