Run Code
|
API
|
Code Wall
|
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
Studiu Individual 1
Microsoft SQL Server T-SQL in 10 mn ~ Lesson 13 Subqueries vers. #5
megha
Foreign keys
SQL for beginners( defined with errors while enforcing constraints)
Arif Secoond Query
joins
db6
Allocations Check
Outer Apply successer cell chek and get the result