insert into table_b
select * from TABLE_A a
where a.id <> (select max(b.id) from TABLE_B b where a.code = b.code);
select * from TABLE_A a
where a.id <> (select max(b.id) from TABLE_B b where a.code = b.code);
解决方案 »
- toad用法
- 谁帮忙看一下METALINK Bug 7308054的信息啊?
- 在一台十几万的服务器上和一台64位PC机上,服务器的速度还要慢,请高手解答
- OracleCommand.ExecuteNonQuery()会自动提交,还是ADO.NET的BUG?
- oracle 数据库打不开了 ;错误 ORA-01219 : 数据库未打开:仅允许在固定表、视图中查询
- Mysql 的time类型 在Oracle对应的类型是什么啊?
- job任务执行了一次,然后就再也不执行了,这是为什么呢?
- 救命啊,ORACLESERVICE起不来了!
- oracle drop table 或者truncate table 问题
- 连接总断的问题
- pro*C/C++ 怎么预编译C++程序?
- 如何将Word文档插入oracle数据库中?
select * from TABLE_A a
where a.id <> (select max(b.id) from TABLE_A b where a.code = b.code);
(
select id,code,name from table_a where rowid in
(select max(rowid) from table_a group by code)
)
select * from TABLE_A a
where a.id = (select min(b.id) from TABLE_A b where a.code = b.code)
minus
select * from TABLE_A c
where c.id = (select max(d.id) from TABLE_A d where c.code = d.code);
select min(id) min_id,code,(select name from table_a t1 where t1.id = min_id)
from table_a group by code
TABLE_A中的字段id类型为字符型,而且,它的值一般都是字符串,如:“aaa”,“bbb”,“ccc”等;而不是依次递增的数字。
所以,用id来判断,恐怕不行丫。