можно ли это сделать одним statement так чтобы не использовать Identity auto-number field?
т.е. таблица типа
Field 1 Field 2 Field3
A B D
A F T
A B D
надо чтобы осталось только 1 и 2я записи (или можно 2я и 3я).
спасибо!
удалить дубликаты в SQL
-
- Уже с Приветом
- Posts: 12262
- Joined: 20 Dec 2000 10:01
- Location: Bellevue, WA
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 12262
- Joined: 20 Dec 2000 10:01
- Location: Bellevue, WA
-
- Уже с Приветом
- Posts: 525
- Joined: 01 May 2002 20:29
- Location: CT->MA->TX->UT
In Oracle I do such things in one statement like this:
delete from your_table_name
where rowid not in (
select rid from (
select max(rowid) rid,
Field1,
Field2,
Field3
from your_table_name
group by Field1,
Field2,
Field3
having count(*) > 1))
delete from your_table_name
where rowid not in (
select rid from (
select max(rowid) rid,
Field1,
Field2,
Field3
from your_table_name
group by Field1,
Field2,
Field3
having count(*) > 1))
In a theory there is no difference
Between theory and reality
But in a reality there is ...
Between theory and reality
But in a reality there is ...
-
- Уже с Приветом
- Posts: 2107
- Joined: 04 Mar 1999 10:01
- Location: Gaithersburg, MD
-
- Уже с Приветом
- Posts: 28294
- Joined: 29 Aug 2000 09:01
- Location: SPB --> Gloucester, MA, US --> SPB --> Paris
-
- Уже с Приветом
- Posts: 2107
- Joined: 04 Mar 1999 10:01
- Location: Gaithersburg, MD
-
- Уже с Приветом
- Posts: 12262
- Joined: 20 Dec 2000 10:01
- Location: Bellevue, WA