Sort employees alphabetically and identify their level of seniority in the company.
SELECT EmployeeName, (HireDate - CURRENT_DATE) AS ServiceDays, RANK(ServiceDays) AS Seniority FROM Employee ORDER BY EmployeeName;
The result may look like the following table.
EmployeeName | Service Days | Seniority |
---|---|---|
Ferneyhough | 9931 | 2 |
Lucier | 9409 | 4 |
Revueltas | 9408 | 5 |
Ung | 9931 | 2 |
Wagner | 10248 | 1 |