查詢及刪除重復記錄的SQL語句
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) >
delete from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) >
and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>
注:rowid為oracle自帶不用該
select * from vitae a
where (a
delete from vitae a
where (a
and rowid not in (select min(rowid) from vitae group by peopleId
select * from vitae a
where (a
and rowid not in (select min(rowid) from vitae group by peopleId
(二)
比方說
在A表中存在一個字段“name”
而且不同記錄之間的“name”值有可能會相同
現在就是需要查詢出在該表中的各記錄之間
Select Name
如果還查性別也相同大則如下:
Select Name
(三)
方法一
declare @max integer
declare cur_rows cursor local for select 主字段
open cur_rows
fetch cur_rows into @id
while @@fetch
From:http://tw.wingwit.com/Article/program/Oracle/201311/19083.html