CREATE TABLE #Department( DepartmentID int NOT NULL PRIMA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

スタック・オーバーフローMeta

プログラマーと熱狂的なプログラマーのためのサイトに関する質問と回答

CREATE TABLE #Department( 
   DepartmentID int NOT NULL PRIMARY KEY, 
   Name VARCHAR(250) NOT NULL, 
) 

INSERT #Department (DepartmentID, Name)  
VALUES (1, N'Engineering') 

INSERT #Department (DepartmentID, Name)  
VALUES (2, N'Administration') 
INSERT #Department (DepartmentID, Name)  
VALUES (3, N'Sales') 
INSERT #Department (DepartmentID, Name)  
VALUES (4, N'Marketing') 
INSERT #Department (DepartmentID, Name)  
VALUES (5, N'Finance') 
GO 

CREATE TABLE #Employee( 
   EmployeeID int NOT NULL PRIMARY KEY, 
   FirstName VARCHAR(250) NOT NULL, 
   LastName VARCHAR(250) NOT NULL, 
   DepartmentID int NOT NULL, 
) 
GO
 
INSERT #Employee (EmployeeID, FirstName, LastName, DepartmentID) 
VALUES (1, N'Orlando', N'Gee', 1 ) 


SELECT A.* FROM #Department D 
LEFT OUTER JOIN
   ( 
   SELECT * FROM #Employee 
--   WHERE E.DepartmentID = D.DepartmentID 
   ) A on A.DepartmentID = D.DepartmentID 
GO

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results