Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Solution 3
/* Problem: Write a SQL statement to list all employees that are not managers. Add your solution at the end. Expected Output: EmployeeId FirstName LastName 3 Mason Farrell 8 Isabella Portman 9 Ethan Firth 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 WHERE NOT EmployeeId IN (SELECT DISTINCT ManagerEmployeeId FROM Employees WHERE ManagerEmployeeId IS NOT NULL )
run
|
edit
|
history
|
help
0
Solution 1
test1
Q2_5MIN
SQL_Joins_RankingFunctions
new problem SQL
Unpivot Example
Sql server 2012 features list
Duplicate Records
MSSQL NVARCHAR to INT conversions
StackOverflow_53753663