To get SQL query for matching dates in two different tables
472206Dec 23 2005 — edited Dec 23 2005Hi all,
I need your help to get a SQL query for the following requirement
Table A contains some eff_dte and table B is also contains some set of eff_dte.
We have to check with table A date value with table B date value.If the A date value is available in B date.We hv to increment the A date value by 1(i mean the next day) and again we have to check whether this incremented value is also available in table B,If it's not there we hv to get that date or else again we have to increment that date value by 1,after checking with table B.
A B
-- ---
12/13/2005 12/15/2005
12/22/2005 12/23/2005
12/23/2005 12/24/2005
12/27/2005 12/30/2005
For more understanding table A contains the 13'Dec, we have to check whether this 12/13 is available in table B.in this case it's not available in B so we are taking the value 12/13 as it is.
And then we are taking the second value 12/23 and checking this one is available in table B.
It's matching with this condition,so we are incrementing this 12/23 date by one ie.,12/24 date and again checking with table B.In this 12/24 is also available,so again we are incrementing this value by next date 12/25.Now the second time we are checking with table B and there is no matching with this table.so that we are taking the value 12/25 as it's.
Thanks in Advance
Senthil K