Select duplicates by PrimaryKey
Both your queries are fine, assuming that (ID) is the primary key of the table (or it has a UNIQUE constraint).

The 2nd query can be simplified, removing the derived table:

SELECT t1.*
FROM table as t1 INNER JOIN 
     table as t2
     ON t2.UserID = t1.UserID AND t2.GroupID = t2.GroupID
WHERE t2.ID = @id ;




For performance, you may need an index on (UserID, GroupID) - with any of the queries.