There are two data tables with employee information: EMPLOYEE and EMPLOYEE_UIN. Query the tables to generate a list of all employees who are less than 25 years old first in order of NAME, then of ID, both ascending.  The result should include the UIN followed by the NAME.  

Note:  While the secondary sort is by ID, the result includes UIN but not ID.

Schema
EMPLOYEE
NameTypeDescription
IDIntegerThe ID of the employee. This is a primary key.
NAMEStringThe name of the employee having [1, 20] characters.
AGEInteger   The age of the employee.
ADDRESSStringThe address of the employee having [1, 25] characters.
SALARYIntegerThe salary of the employee.
EMPLOYEE_UIN
NameTypeDescription
IDIntegerThe ID of the employee. This is a primary key.
UINStringThe unique identification number of the employee.
Sample Data Tables

Sample Input

EMPLOYEE
IDNAMEAGEADDRESSSALARY
1Sherrie23Paris74635
2Paul30Sydney72167
3Mary24Paris75299
4Sam47Sydney46681
5Dave22Texas11843
EMPLOYEE_UIN
IDUIN
157520-0440
249638-001
363550-194
468599-6112
563868-453

 

Sample Output

63868-453 Dave
63550-194 Mary
57520-0440 Sherrie

 

 

Explanation

  • Sherrie is 23 years old and has UIN 57520-0440.  This record is printed.
  • Paul is 30 years old and has UIN 49638-001.  This record is not printed.
  • A similar analysis is done on the remaining records.

None of the three names of people less than 25 years old is repeated, so print them in alphabetical order.  There is no additional sorting by ID in this case.

Solution:

				
					SELECT EU.UIN, E.NAME
FROM EMPLOYEE AS E
JOIN EMPLOYEE_UIN AS EU ON E.ID = EU.ID
WHERE E.AGE < 25
ORDER BY E.NAME ASC, E.ID ASC;