Hello,
I am trying to find the duplicates in a table while joining another one. Here are my tables:
**game**
id, productCode, productDescription, status
**gamePins**
id gameID pin serial
SELECT id, productCode, productDescription, status, gb.Pin, gb. Serial
FROM [GameAPI].[dbo].[GameBanks] g
inner join GameBankPins gb on g.GameBankID = gb.id
where gb.pin in (
SELECT gb.pin
FROM [GameAPI].[dbo].[GameBanks] g
inner join GameBankPins gb on g.GameBankID = gb.id
GROUP BY gb.Pin, gb.Serial
HAVING COUNT(*) > 1
)
I wonder if I can only get duplicates which have status = 0 (7,8,9 below)
id | productCode | productDescription | status | id | gameID | pin | serial | |
---|---|---|---|---|---|---|---|---|
1 | a | product a | 0 | 1 | 1 | 123 | 445rtg | |
2 | b | product b | 1 | 2 | 2 | 123 | 445rtg | |
3 | c | product c | 0 | 3 | 3 | 123 | 445rtg | |
4 | a | product a | 2 | 4 | 4 | 456 | abc | |
5 | a | product a | 0 | 5 | 5 | 456 | abc | |
6 | a | product a | 1 | 6 | 6 | 456 | abc | |
7 | d | product d | 0 | 7 | 7 | 789 | 11ee | |
8 | a | product a | 0 | 8 | 8 | 789 | 11ee | |
9 | c | product c | 0 | 9 | 9 | 789 | 11ee |