xxxxxxxxxx
SELECT columnName, COUNT(columnName)
FROM tableName
GROUP BY columnName
HAVING COUNT(columnName)>1
xxxxxxxxxx
SELECT name, COUNT(email)
FROM users
GROUP BY email
HAVING COUNT(email) > 1
xxxxxxxxxx
SELECT column1, column2, COUNT(*)
FROM table_name
GROUP BY column1, column2
HAVING COUNT(*) > 1;
xxxxxxxxxx
SELECT column_name, COUNT(column_name) AS count
FROM table_name
GROUP BY column_name
HAVING COUNT(column_name) > 1;
xxxxxxxxxx
SELECT OrderID, COUNT(OrderID)
FROM Orders
GROUP BY OrderID
HAVING COUNT(OrderID) > 1
xxxxxxxxxx
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