Returning the dupes is something like this:
Code:
SELECT pyStudent, pyClass, pyPaid
FROM tblPay
GROUP BY pyStudent, pyPaid, pyClass
HAVING COUNT(*)>1
...but in order to get the values for the extra field, you either need to get only the min/max value (just add it to the Select list), or use the above as a sub-query to join to, eg:
Code:
SELECT P1.pyID, P1.pyStudent, P1.pyClass, P1.pyPaid
FROM tblPay P1
INNER JOIN (
SELECT pyStudent, pyClass, pyPaid
FROM tblPay
GROUP BY pyStudent, pyPaid, pyClass
HAVING COUNT(*)>1
) as P2 on (P1.pyStudent = P2 pyStudent AND P1.pyPaid = P2.pyPaid AND P1.pyClass = P2.pyClass)