【发布时间】:2013-10-03 21:41:27
【问题描述】:
在 TABLE_A 中,每个 ID 都有一个最小 SDT 和最大 EDT。
例如:对于 ID=1000,这将是 1/09/2013 和 3/10/2013。
例如:对于 ID=1001,这将是 1/07/2013 和 3/08/2013。
预期结果将是 TABLE_B 中的所有记录,其中 TABLE_B 中的 SDT 介于 TABLE_A 中的最小 SDT 和最大 EDT 值之间。
TABLE_A
ID SDT EDT
------------------------------
1000 1/10/2013 3/10/2013
1000 1/09/2013 3/09/2013
1001 1/08/2013 3/08/2013
1001 1/07/2013 3/07/2013
1002 1/06/2013 3/06/2013
TABLE_B
ID SDT
-----------------
1000 2/10/2013 ===> because it falls between 1/09/2013 and 3/10/2013
1000 4/09/2013 ===> because it falls between 1/09/2013 and 3/10/2013
1001 2/08/2013 ===> because it falls between 1/07/2013 and 3/08/2013
1001 4/05/2013 ==> not in result because it's not between 1/07/2013 and 3/08/2013
1002 4/06/2013 ==> also out of range, so not in results
【问题讨论】:
标签: sql date oracle11g date-range