sql中的conditions是在select,delete,update语句常常用到的,其中range condition只包含:(not)between..and.
2)oracle的between..and..前后都是闭区间,也就是说包含两个端的数,例如:
SELECT * FROM employees
WHERE salary
BETWEEN 2000 AND 3000;查询返回 2000<=工资<=3000的员工
3)当前者数大于后者,如:salary between 100 and 10;此时不会出错,但salary为50的记录也不能被取出。
4)not between..and..只是取指定范围的相反范围,也就是不在这个范围的记录,其用户可以用组个逻辑条件来取代。
SELECT MONTHS_BETWEEN (TO_DATE ('2003/01/01', 'yyyy/mm/dd'), TO_DATE ('2003/03/14', 'yyyy/mm/dd')) FROM dual;
returns -2.41935483870968
SELECT MONTHS_BETWEEN (TO_DATE ('2003/07/01', 'yyyy/mm/dd'), TO_DATE ('2003/03/14', 'yyyy/mm/dd')) FROM dual;
returns 3.58064516129032
下面查找月份
MONTHS_BETWEEN(
, )
SELECT MONTHS_BETWEEN(SYSDATE+365, SYSDATE-365) FROM dual;
SELECT MONTHS_BETWEEN(SYSDATE-365, SYSDATE+365) FROM dual;