我正在对下面的数据进行查询
A B C D E
----- -------- -------- --- ---
1 20140911 20140916 HPS 32
2 20140901 20140901 PLV 8
3 20140901 20140903 HPS 24
当我运行此查询时
select A, B, C, D, E
from TABLE1 where (A = '1') and
(
( B >= 20140915 AND C <= 201401012 )
OR
( B < 20140915 AND C > 201401012 )
OR
( C > 201401012 AND B <= 201401012 AND B >= 20140915 )
OR
( C >= 20140915 AND C <= 201401012 AND B < 20140915 )
)
作为输出我得到了
A B C D E
----- -------- -------- --- ---
1 20140911 20140916 HPS 32
在查询时我添加一个条件( AND D ='HPS'),如下所示
select A, B, C, D, E from TABLE1 where (A = '1' AND D = 'HPS')
and
(
( B >= 20140915 AND C <= 201401012 )
OR
( B < 20140915 AND C > 201401012 )
OR
( C > 201401012 AND B <= 201401012 AND B >= 20140915 )
OR
( C >= 20140915 AND C <= 201401012 AND B < 20140915 )
)
它不会返回任何输出。我无法理解为什么会这样。