Here goes my table values. ( 7 Records )
SELECT * FROM tbl1
I can’t post the image as my rep is low. So i am linking it here
https://i.stack.imgur.com/CFl0u.png
I wrote a query to avoid the last record, but i am still getting the last record. (ALL I NEED IS DISTINCT EMAILS)
SELECT DISTINCT CandEmail,CandName,EmployerId,ContNum,IsDeleted,CandPortalId FROM tbl1
WHERE EmployerId = 7 AND IsDeleted = 0
The above query still retrieves the same 7 records with last duplicate email record.
If you do not care which
ContNumyou get, then you can place an aggregate function around that field and thenGROUP BYthe rest:Or as others have pointed out, you should use aggregate functions on the other fields as well, unless you know for sure there are not different values in those columns: