Entfernung habe ich eine Tabelle wie folgt aus:Wählen Sie Abfrage nach relevanten Daten während Duplikate
ID Col_A Col_B Col_C Col_D Col_E Col_F Col_G Col_H
1 yyy null NULL NULL NULL NULL NULL 1
1 yyy null NULL NULL NULL NULL NULL null
1 yyy null NULL NULL NULL NULL NULL 0
1 yyy null NULL NULL NULL NULL NULL null
1 yyy null NULL NULL NULL NULL NULL 0
26 null 17,5 NULL NULL NULL NULL NULL null
26 null 17,5 NULL NULL NULL NULL NULL 1
26 null 17,5 NULL NULL NULL NULL NULL 0
26 null 17,5 NULL NULL NULL NULL NULL 0
26 null 17,5 NULL NULL NULL NULL NULL 1
ich doppelte IDs entfernen möchten, aber relevante Daten zu halten. Also hier gewünschte Ergebnis wäre:
ID Col_A Col_B Col_C Col_D Col_E Col_F Col_G Col_H
1 yyy null NULL NULL NULL NULL NULL 1
26 null 17,5 NULL NULL NULL NULL NULL 1
Der Code, den ich versuchte, war:
SELECT ID,
MAX (ISNULL (Col_A, 0)) AS Col_A,
MAX (ISNULL (Col_B, 0)) AS Col_B,
MAX (ISNULL (Col_C, 0)) AS Col_C,
MAX (ISNULL (Col_D, 0)) AS Col_D,
MAX (ISNULL (Col_E, 0)) AS Col_E,
MAX (ISNULL (Col_F, 0)) AS Col_F,
MAX (ISNULL (Col_G, 0)) AS Col_G,
MAX (ISNULL (Col_H, 0)) AS Col_H
FROM TableA
GROUP BY ID
ORDER BY 1
Arbeiten an MSSQL 2008
Ich habe den Titel bearbeitet, da Sie eigentlich keine Dubletten aus Ihrer Tabelle entfernen möchten, sondern nur nicht duplizierte Datensätze. –