MatchDate ColA ColB PossibleDate
01/01/2012 ABC 123 01/01/2012
01/01/2012 ABC 123 09/01/2012
01/01/2012 ABC 123 01/15/2013
09/01/2012 ABC 123 01/01/2012
09/01/2012 ABC 123 09/01/2012
09/01/2012 ABC 123 09/13/2012
09/01/2012 ABC 123 10/11/2012
09/01/2012 ABC 123 01/15/2013
01/15/2013 ABC 123 01/01/2012
01/15/2013 ABC 123 09/01/2012
01/15/2013 ABC 123 01/15/2013
01/15/2013 ABC 123 02/22/2013
08/15/2012 XYZ 777 08/15/2012
08/15/2012 XYZ 777 08/28/2012
08/15/2012 XYZ 777 10/11/2012
08/15/2012 XYZ 777 01/15/2013
01/15/2013 XYZ 777 01/15/2013
01/15/2013 XYZ 777 08/15/2012
私が探している結果:
MatchDate ColA ColB PossibleDate
01/01/2012 ABC 123 NULL
09/01/2012 ABC 123 09/13/2012
09/01/2012 ABC 123 10/11/2012
01/15/2013 ABC 123 02/22/2013
08/15/2012 XYZ 777 08/28/2012
08/15/2012 XYZ 777 10/11/2012
01/15/2013 XYZ 777 NULL
一意の「MatchDate、ColA、および ColB」列ごとに行を返し、MatchDate と PossibleDate の間にある「可能な日付」を返す必要があります。
各列が有効な理由とそうでない理由を説明するメモを追加しました。
MatchDate ColA ColB PossibleDate (Notes)
01/01/2012 ABC 123 01/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
01/01/2012 ABC 123 09/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
01/01/2012 ABC 123 01/15/2013 (Not valid as it's MatchDate already exists for "ABC, 123")
09/01/2012 ABC 123 01/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
09/01/2012 ABC 123 09/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
09/01/2012 ABC 123 09/13/2012 (VALID as it's PossibleDate is NOT a MatchDate and it's between 09/01/2012 and the next possible MatchDate of 01/15/2013 for "ABC, 123")
09/01/2012 ABC 123 10/11/2012 (VALID as it's PossibleDate is NOT a MatchDate and it's between 09/01/2012 and the next possible MatchDate of 01/15/2013 for "ABC, 123")
09/01/2012 ABC 123 01/15/2013 (Not valid as it's MatchDate already exists for "ABC, 123")
01/15/2013 ABC 123 01/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
01/15/2013 ABC 123 09/01/2012 (Not valid as it's MatchDate already exists for "ABC, 123")
01/15/2013 ABC 123 01/15/2013 (Not valid as it's MatchDate already exists for "ABC, 123")
01/15/2013 ABC 123 02/22/2013 (VALID as it's PossibleDate is NOT a MatchDate and it's between 01/15/2013 and the next possible MatchDate, which doesn't exist as it's the largest MatchDate for "ABC, 123")
08/15/2012 XYZ 777 08/15/2012 (Not valid as it's MatchDate already exists for "XYZ, 777")
08/15/2012 XYZ 777 08/28/2012 (VALID as it's PossibleDate is NOT a MatchDate and it's between 08/15/2012 and the next possible MatchDate of 01/15/2013 for "XYZ, 777")
08/15/2012 XYZ 777 10/11/2012 (VALID as it's PossibleDate is NOT a MatchDate and it's between 08/15/2012 and the next possible MatchDate of 01/15/2013 for "XYZ, 777")
08/15/2012 XYZ 777 01/15/2013 (Not valid as it's MatchDate already exists for "XYZ, 777")
01/15/2013 XYZ 777 01/15/2013 (Not valid as it's MatchDate already exists for "XYZ, 777")
01/15/2013 XYZ 777 08/15/2012 (VALID as it's PossibleDate is NOT a MatchDate and it's between 01/15/2013 and the next possible MatchDate, which doesn't exist as it's the largest MatchDate for "XYZ, 777")
前もって感謝します...あまり混乱しないことを願っています。