Q:

SQL, OR AND STATEMENT

Does the AND Statement after the OR statement have the same logic as something similar to
where  d.res_id = 125 and t.task_type in( 'PPB', 'PPO') 
 and 
  d.status = ('C')
 OR 
  d.status IN ('R' ,'D') 
     AND
    t.done_dt = DATEADD(month, -1, GETDATE())

where  d.res_id = 125 and t.task_type in( 'PPB', 'PPO')
IF d.status  IN ('R','D')
  t.done_dt = DATEADD(month, -1, GETDATE())
 ELSE 
  d.status = 'C'

Which one is the correct way to format it?
I'm trying to display all d.status with the 'C' status. But only if the t.done_dt is the previous month, do I want to display d.status IN ('R', 'D')

A:

I guess you want to translate this pseudo code into SQL? 
where  d.res_id = 125 and t.task_type in( 'PPB', 'PPO')
AND
 IF d.status  IN ('R','D')
     t.done_dt = DATEADD(month, -1, GETDATE())
 ELSE 
     d.status = 'C'

That would be:
where  d.res_id = 125 and t.task_type in( 'PPB', 'PPO')
AND (    ( d.status = 'C' )  -- SHOW ALL 'C'
      OR ( d.status  IN ('R','D') and t.done_dt = DATEADD(month, -1, GETDATE()) )
                             -- SHOW ALL R,D on that date
    )

