1SELECT username, email, COUNT(*)
2FROM users
3GROUP BY username, email
4HAVING COUNT(*) > 1
5
1SELECT name, COUNT(email)
2FROM users
3GROUP BY email
4HAVING COUNT(email) > 1
1declare @YourTable table (id int, name varchar(10), email varchar(50))
2
3INSERT @YourTable VALUES (1,'John','John-email')
4INSERT @YourTable VALUES (2,'John','John-email')
5INSERT @YourTable VALUES (3,'fred','John-email')
6INSERT @YourTable VALUES (4,'fred','fred-email')
7INSERT @YourTable VALUES (5,'sam','sam-email')
8INSERT @YourTable VALUES (6,'sam','sam-email')
9
10SELECT
11 name,email, COUNT(*) AS CountOf
12 FROM @YourTable
13 GROUP BY name,email
14 HAVING COUNT(*)>1