I just started taking a database class and we’re learning SQL.
I have a table that has several columns. The last two columns are the first name and the last name of a person. No two people have the same last name, and I want to sort the table by the person’s name (first and last) and show something like :
Trainee FirstName || Trainee LastName || Trainer FirstName || Trainer LastName ||
AAA || BB || Tom || Banks ||
Test || Test || || ||
CCC || DD || || ||
Another || PERSON || Susan || Lee ||
… etc.
I can get it so the duplicate last names don’t show up by doing :
break on lastname;
select .... order by T.lastname,
but I can’t figure out how to get the first names to not duplicate as well.
Help would really be appreciated, I’ve looked around online and I’ve been able to do a lot of the other exercises, but I can’t figure out how to do this one.
Are you supposed to solve this problem by limiting the output or by preventing duplicates from entering the database in the first place?
If you are trying to limit the output, look into the
DISTINCToperation ofSELECT.