SQL> create table aaaaa (a char(10),b date);表已创建。SQL> select a,b,months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd')))
2 from aaaaa
3 where months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd'))) >= 1
4 order by b;未选定行SQL> select a,b,months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd')))
2 from aaaaa
3 where months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd'))) = 1
4 order by b;未选定行好像没有什么问题
2 from aaaaa
3 where months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd'))) >= 1
4 order by b;未选定行SQL> select a,b,months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd')))
2 from aaaaa
3 where months_between(last_day(sysdate),last_day(to_date(b,'yyyy-mm-dd'))) = 1
4 order by b;未选定行好像没有什么问题
解决方案 »
- Oracle 多用户共用临时表问题
- []求各位高手帮帮忙,关于读取结果写入文件的问题
- 存储过程访问另外一个数据库,除了dblink,还有什么连接方法
- hsqldb
- 提供一个好地方
- 能通过dblink调用远程的存储过程吗?
- ORACLE查询
- 救命,请问怎么在XP下装ORACLE8.1.7,急!(100分)
- Oracle7.3.3升级8.1.6的问题
- 在P4机子上ORACLE8.0.5 CLIENT NET8 配置问题.........,急!!!!!!!!!!!!!!!!!!
- oracle8.05+develop2000开发的程序在oracle9i+oracle6i下为什么不能运行?
- 我想知道,在Oracle中写存储过程的步骤
怎用了to_date()函数呢,非法的.select a,b,months_between(last_day(sysdate),last_day(b))
from table
where months_between(last_day(sysdate),last_day(b)) >= 1
order by b;
To_date(b,'yyyy-mm-dd')2 不明白?返回的是月数 怎么会不能比较大小呢?
select a,b,months_between(trunc(sysdate,'mm'),trunc(b,'mm'))
from table
where months_between(trunc(sysdate,'mm'),trunc(b,'mm'))>= 1
order by b;
SQL> select months_between(to_date('2003-1-10','yyyy-mm-dd'),to_date('2002-6-10','yyyy-mm-dd')) from dual;MONTHS_BETWEEN(TO_DATE('2003-1
------------------------------
7
select a,b,to_number(to_char(sysdate,'yyyymmdd'))-to_number(to_char(b,'yyyymmdd')) c from table where c>=1 order by b;
select a,b,to_number(to_char(sysdate,'yyyymm'))-to_number(to_char(b,'yyyymm')) c from table where c>=1 order by b;
我的语句没有问题问题在于数据,比方我在where 条件中加一个rownum<24就可以,>=24就不行
[email protected]