1 select * from table1
where dwbm='1001' and id=x3 and insert_date=max(insert_date)
where dwbm='1001' and id=x3 and insert_date=max(insert_date)
解决方案 »
- 两表查询,在一个表统计另一表中的数
- oracel中两个timestamp差值的问题?
- oracle 建表语句
- 关于oracle的number数据类型的精度问题
- 在Oracle10g中,对一个分区过的表做分析,结果。。。。。
- sql转换
- 我编写了自己的第一个trigger里面有错误,找不到原因
- 程序语言开发中 怎么取得oracle的数据操作错误 ?
- 创建表空间时出错:'c:\oracle\oradata\cnc\lgy.ora'出错,无法创建文件,无法打开文件,系统找不到指定的路径!
- exp导出时,选择u(用户)时,导出的是什么内容?清高手指点
- 我用oracle management server登录进去后,怎么没有数据库的信息?
- 如何在sqlplus下声明一个日期变量================================?
只筛选出日期最近的,id=x3的记录(只一行就可以了)select
a.*
from
table1 a
where
a.dwbm='1001'
and
not exists(select * from table1 where dwbm=a.dwbm and insert_date>a.insert_date)
id=x3和id=x4
另外,单位不止2个,insert_date是字符型字段.select
a.*
from
table1 a
where
not exists(select * from table1 where dwbm=a.dwbm and insert_date>a.insert_date)
select
a.*
from
table1 a,
(select dwbm,max(insert_date) as insert_date from table1 group by dwbm) b
where
a.dwbm='1001'
and
a.dwbm=b.dwbm
and
a.insert_date=b.insert_date2、
select
a.*
from
table1 a,
(select dwbm,max(insert_date) as insert_date from table1 group by dwbm) b
where
a.dwbm=b.dwbm
and
a.insert_date=b.insert_date
select aa.* from table1 aa,(select dwbm,max(insert_date) from table1 group by dwbm) bb
where aa.dwbm=bb.dwbm and aa.insert_date=bb.insert_date