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 大数据量表中的日期类型字段创建索引效率高吗?
- 传统order by和分析函数结果不一致
- oracle日期类型问题
- 某段时间总数统计
- ROWNUM这种效果能不能用什么办法在MYSQL的查询结果集中实现?
- 数字计算正确,插入表中错误?
- 从WINDOWS2000的管理工具中启动oracle manangementserver出现错误!!!
- 未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序?在线等待!
- Oracle中,使用hash建立分区的表,如何知道数据在哪一个分区?
- 请教一个 linux 上安装oracle11g 提示无法使用命令 /usr/bin/xdpyinfo 问题谢谢
- 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]