Excluding Records from 60 days prior to data set that match a criteria

  • I have a data set of two years worth of data, and I want to exclude records that match a criteria in previous 60 days data.

    Scenario:

    Start Date =  1st day of 24 months ago (t-2y)
    End  Date  =  Last day of Last Month

    select  from  [my table]
    everything that fits my criteria
    one record of my select = log_id
    where records within 24 months
    Now, I want to exclude any record above that matches  log_id  prior to 24 months ago

    IF log-_id from my data set = log_id from records 60 days prior to t-2y. 

    I  need to know how to properly exclude records from my data set
    1. 07/01/2017 Log_id = 7 in my select
    2. 06/01/2017  Log_id = 7
    Exclude record 2 because it exists in the window of -60 days

    Thank you.

  • Without sample data, it's a lot harder to answer your question.  Since you're new, please read Jeff's article on how to post a question - he outlines how to ask a question that gets answered. Forum Etiquette: How to post data/code on a forum to get the best help

    Not totally sure what you mean by "matches log_id prior to 24 months ago"
    DATEADD(month, -24, [log_date])   ?

    Sounds like EXISTS maybe with a correlated subquery.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply