0

I'm trying to get the records based on the last 30 days of the comment_date and a create_user_id. So for user_id 'BOB' it shouldn't be returning any records since there are records for 2/13 and 2/14 (which is within the 30-days of the comment_date). The same goes for 'STEVE', 'JOHN' and 'KEN'. How do I write the query for user_id 'TOM'(case 2), 'KEN'(case 3), and 'ROSS'(case 4)? Thanks

comments_sk case    comments         create_user_id   comment_date
120          1      user_comment-1      JOHN           2/16/2017
121          1      user_comment-2      BOB            2/14/2017
122          1      user_comment-3      BOB            1/13/2017
123          2      user_comment-1      BOB            2/13/2017
124          2      user_comment-2      STEVE          2/13/2017
125          2      user_comment-3      TOM            1/13/2017
126          3      user_comment-1      JOHN           2/12/2017
127          3      user_comment-2      JOHN           1/12/2017
128          3      user_comment-3      KEN            1/11/2017
129          4      user_comment-1      KEN            2/14/2017
130          4      user_comment-2      ROSS           1/7/2017

1 Answers1

1
 SELECT * 
 FROM 
      Your_Table 
 WHERE 
      Comment_date >= DATEADD(day,-30, GETDATE())  
      and Create_user_id in ('KEN','TOM','ROSS')
      and Comments = ''
Kinchit Dalwani
  • 398
  • 4
  • 19