Select distinct can remove duplicate records.
Disctinct ignores duplicate records, but it ignores identical duplicate records, not records that are duplicated in one of these fields, or where a distinct queries a field so that multiple fields are not.
So using aggregate functions and GROUP by implementations
Note: Group by can only be used with aggregate functions
Example table
ID username Password Trdesc ........ ......... ...
1 A abcdef QR
2 A abcdef W34
3 A bbbbbb AD
4 B aaaaaa ASDF
Query username and password combination of conditions can not be repeated query results (this can be repeated, not to mention that this is a mess)
When username and password Repeat, take the record with the largest ID:
SELECT * FROM MyTable where ID in (select Max (ID) from MyTable Group by Username,password)
When username and password Repeat, take the record with the lowest ID:
SELECT * FROM MyTable where ID in (select min (ID) from MyTable a group by Username,password)