“Finden Sie Duplikate in Spalte SQL” Code-Antworten

Finden doppelter Spaltenwerte in der Tabelle mit SQL

SELECT username, email, COUNT(*)
FROM users
GROUP BY username, email
HAVING COUNT(*) > 1
Cucumberman

SQL -Abfrage, um Duplikate in der Spalte zu finden

SELECT name, COUNT(email) 
FROM users
GROUP BY email
HAVING COUNT(email) > 1
Unusual Unicorn

Holen Sie sich doppelte Datensätze in SQL

Multiple field=
SELECT username, email, COUNT(*)
FROM users
GROUP BY username, email
HAVING COUNT(*) > 1

Single field=
SELECT _column, COUNT(*) 
FROM _table
GROUP BY _column
HAVING COUNT(*) > 1
Obedient Ocelot

So erhalten Sie doppelte Werte in SQL

• SELECT first_name, COUNT (first_name) FROM employees
GROUP BY first_name
HAVING (COUNT(first_name) > 1);
Obedient Ocelot

Finden Sie Duplikate in Spalte SQL

declare @YourTable table (id int, name varchar(10), email varchar(50))

INSERT @YourTable VALUES (1,'John','John-email')
INSERT @YourTable VALUES (2,'John','John-email')
INSERT @YourTable VALUES (3,'fred','John-email')
INSERT @YourTable VALUES (4,'fred','fred-email')
INSERT @YourTable VALUES (5,'sam','sam-email')
INSERT @YourTable VALUES (6,'sam','sam-email')

SELECT
    name,email, COUNT(*) AS CountOf
    FROM @YourTable
    GROUP BY name,email
    HAVING COUNT(*)>1
Motionless Mantis

Ähnliche Antworten wie “Finden Sie Duplikate in Spalte SQL”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen