alter session set nls_date_format='YYYY-MM-DD';select * from tablename
where id like 'P479%'
and buy_date=(select max(buy_date) from tablename);
where id like 'P479%'
and buy_date=(select max(buy_date) from tablename);
解决方案 »
- SQL语句VARCHAR2()类型转化为NUMBER类型
- PL/SQL优化问题,急.
- oracle报ORA-600 [6191] or ORA-600 [6193] 错误的解决
- 100分求一个存储过程,急!
- ORA-12541: TNS:没有监听器
- 监听程序添加地址时出现“要求有效的日志文件”?我有监听器,listener.ora文件和tnsnames.ora文件都有,都配置好了。。。
- 一个简单的存储过程,问题有点怪怪!
- 用wrap加密包体出错,请各位大虾帮忙,急!急!急!
- 一个oracle导出文本文件的问题,急,在线等待,请大家帮我。
- 菜鸟求助
- 谁有LoadRunner?请告知下载地址,这是一个古老的经典游戏。
- pl/sql简单问题
就是數據庫中有几條紀錄就查出几紀錄,因為這個是個模糊查詢,好像是要用到 like %P479% 的.
alter session set nls_date_format='YYYY-MM-DD';--選擇最近的日期
select max(buy_date) from tablename
where to_date(buy_date)<>to_date(sysdate);--選擇妳需要的結果
select * from tablename
where id like 'P479%'
and buy_date=(select max(buy_date)
from tablename
where to_date(buy_date)<>to_date(sysdate));
where id like 'P479%'
and exists(select 1 from (select id,max(buy_date) maxdt from tablename
group by id) t where t.id=tablename.id and t.maxdt=tablename.buy_date);
內層查詢select max(buy_date) from tablename where to_date(buy_date)<>to_date(sysdate));
只能查詢系統中所有料號的最大日期,而且只有一個值,而我要的是根據料號進行
分組的,thank you all the same!
select id,max(buy_date) recent_date
from tablename
where where to_date(buy_date)<>to_date(sysdate)
group by id;而后
select * from tablename t,v_tablename v
where t.id like 'P479%'
and t.id=v.id
and t.buy_date=v.recent_date