Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Solution 1
/* Problem: Write a SQL statement to list all employees alphabetically by last name (A-Z). Add your solution at the end. Expected Output: EmployeeId FirstName LastName 2 Liam Brolin 1 Noah Clooney 6 William Damon 3 Mason Farrell 9 Ethan Firth 5 Jacob Foxx 7 Olivia Johansson 4 Emma Jolie 8 Isabella Portman 10 Emily Theron */ -- Create a table called Employees CREATE TABLE Employees ( EmployeeId INT PRIMARY KEY, FirstName VARCHAR(200), LastName VARCHAR(200), ManagerEmployeeId INT) GO -- Fill Employee table INSERT INTO Employees VALUES(1, 'Noah', 'Clooney', NULL) INSERT INTO Employees VALUES(2, 'Liam', 'Brolin', 1) INSERT INTO Employees VALUES(3, 'Mason', 'Farrell', 1) INSERT INTO Employees VALUES(4, 'Emma', 'Jolie', 1) INSERT INTO Employees VALUES(5, 'Jacob', 'Foxx', 2) INSERT INTO Employees VALUES(6, 'William', 'Damon', 4) INSERT INTO Employees VALUES(7, 'Olivia', 'Johansson', 5) INSERT INTO Employees VALUES(8, 'Isabella', 'Portman', 1) INSERT INTO Employees VALUES(9, 'Ethan', 'Firth', 6) INSERT INTO Employees VALUES(10, 'Emily', 'Theron', 7) GO ------------------------------------------------------------------ -- Sql Server 2014 Express Edition - 12.0.2000.8 -- Solution. ------------------------------------------------------------------ SELECT EmployeeId, FirstName, LastName FROM Employees ORDER BY LastName
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
group_concat in sql-server
Manish SQL
Empleados
Alquileres
Demo
Employee Table
Recursive CTE termination
Get amount of users that bought something soon after registration
a
a
Please log in to post a comment.