Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Exam_1
--Sql Server 2014 Express Edition --Batches are separated by 'go' CREATE TABLE Department( DeptID int IDENTITY PRIMARY KEY NOT NULL, DepartmentName varchar(255), ); CREATE TABLE Country( ID int IDENTITY PRIMARY KEY NOT NULL, Country varchar(255), RetirementAge int ); CREATE TABLE Employee( EmployeeID int IDENTITY PRIMARY KEY NOT NULL, DeptID int FOREIGN KEY REFERENCES Department(DeptID), CountryID int FOREIGN KEY REFERENCES Country(ID), EmployeeName varchar(255), EmployeeAge int ); go INSERT INTO Department(DepartmentName) VALUES ('IT'),('Marketing'),('Sales'),('HR'); INSERT INTO Country(Country,RetirementAge) VALUES ('IN',65),('RU',55),('CH',70),('NE',65); SELECT * FROM Department; SELECT * FROM Country; INSERT INTO Employee(DeptID,CountryID,EmployeeName,EmployeeAge) VALUES(1,1,'Neerad',25),(1,1,'Shivam',26),(4,2,'Sasha',24),(2,1,'Harsh',27),(1,3,'Xing',23),(3,4,'Siman',70); SELECT * FROM Employee; go SELECT EmployeeName FROM Employee WHERE EmployeeAge IN (SELECT RetirementAge FROM Country);
run
|
edit
|
history
|
help
0
Running Total
Sum then delete one row
RH
Insert multiple parent-child records
c12part2
self join - SQL
ms sql - update/insert - date concatenation
Me
Solution 3
SQL_Joins_RankingFunctions