Forum: SQL |
Thema:
Re: Duplikate entfernen ... |
Von:
Thomas Golla (
06.12.2004 09:25) |
Hi :-)
Mal sehen ob ich dein Problem richtig verstanden habe:
Du hast eine Tabelle ähnlich dieser (bloß mit mehr Spalten und Reihen :-)
id werta wertb wertc wertd
1 A A B B
2 A A B C
3 A B B D
4 A C C D
5 A E E E
6 F F F F
7 G F G G
8 G G G G
9 Z Z Z Z
...
Um alle Zeilen herauszubekommen die in einer Spalte einen doppelten Wert haben würde ich folgende SQL Anweisung ausprobieren:
select id, werta, wertb, wertc, wertd
from testo
where werta in (select tab1.werta from (select werta, count(werta) as 'cwerta' from testo group by werta having count(werta) > 1) as "tab1")
or wertb in (select tab2.wertb from (select wertb, count(wertb) as 'cwertb' from testo group by wertb having count(wertb) > 1) as "tab2")
... (hier geht es dann weiter für die anderen Spalten ...)
Hoffe es hilft bzw. ist ein Gedankenanstoss
Lieben Gruß
Tom
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!