'SQL for finding multiple column matches (dups)
I'm trying to write a query to find all rows that have three columns in common with other rows. Imagine a person can only send one letter to another per day and I need to identify "dups" even though all of the columns may not be the same.
I want to see all rows that have the same Sender_ID AND Recipient_ID AND SendDate in common with at least one other row.
SELECT
Sender_ID, Recipient_ID, SendDate
FROM
Letter_Info
WHERE
??????
Is this a nightmare to write or am I just missing the simple solution?
Solution 1:[1]
SELECT Sender_ID, Recipient_ID, SendDate, COUNT(*)
FROM Letter_Info
GROUP BY Sender_ID, Recipient_ID, SendDate
HAVING COUNT(*) > 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
