SQL查询&gt; sysdate <sysdate + =“”1 =“”year =“”

时间:2016-12-02 18:54:55

标签: sql sysdate

=“”

我正在尝试编写一个查找最大到期时间的查询约会,但我注意到的是,当我这样做时,如果我有一个到期日期,我可以说没有结果,比如30-Dec-16,对于同一部分我也有一个到期日期为01-Jan-2099(这是默认的日期,如果没有填写)下面是我的查询我怎么能​​重写expiration_date查询以获得正确的日期。

SELECT 
 Part,
 price,
 effective_date,
 expiration_date
FROM a.Table 
 WHERE Part IN ('&Part') 
 AND PRICE  IN ('somewere') 
 AND expiration_date IN (SELECT 
                          MAX(expiration_date) 
                          FROM table  
                          WHERE expiration_date > SYSDATE 
                          AND  part IN ('&Part)  
                          AND PRICE IN (Somewere)) 
 AND to_date(effective_date) IN (SELECT 
                                  MAX(EFFECTIVE_DATE) FROM b.table  
                                  WHERE expiration_date > SYSDATE 
                                  AND  Part IN ('&Part)  
                                  AND price  IN (somewere) 
                                  AND EFFECTIVE_DATE < SYSDATE + 1)

0 个答案:

没有答案