I having this problem with query these two table do not have any link between and I am trying to combine. Table 1 have effective and expiration date in which have to be tied to table 2 of PollDate. PollDate must not lies in between the effective and expiration date.
Table 1
ClientID EffectiveDate ExpirationDate
1 2009-04-01 00:00:00.000 2009-12-18 00:00:00.000
1 2010-02-12 00:00:00.000 2010-03-05 00:00:00.000
1 2010-05-18 00:00:00.000 NULL
1 2009-12-21 00:00:00.000 2010-02-08 00:00:00.000
1 2010-12-19 00:00:00.000 2009-12-20 00:00:00.000
Table 2
ClientID PollDate
1 2009-12-20 00:00:00.000
1 2009-12-19 00:00:00.000
1 2010-02-12 00:00:00.000
1 2010-02-27 00:00:00.000
1 2010-05-19 00:00:00.000
1 2010-05-29 00:00:00.000
1 2010-05-30 00:00:00.000
1 2010-05-31 00:00:00.000
1 2010-06-05 00:00:00.000
1 2010-06-25 00:00:00.000
1 2010-06-27 00:00:00.000
1 2010-07-02 00:00:00.000
1 2010-08-04 00:00:00.000
1 2010-08-20 00:00:00.000
Result
ClientID inValidDate
1 2009-12-20 00:00:00.000
1 2009-12-19 00:00:00.000
The following is a slight variation of @AJP’s result – just accounting for NULL values in
ExpirationDate: