select * from employee
select MAX(salary) from employee
select * from employee where salary in (select MAX(salary) from employee1daffa)
create database sqlserverbeginner
use
sqlserverbeginner
--sqlserverbeginner
sampledatabase
create table Department(
dept_no varchar(20),
dept_name varchar(50),
location varchar(50)
)
insert into Department values('d1','Research','Dallas')
insert into Department values('d2','Accounting','Seattle')
insert into Department values('d3','Marketing','Dallas')
select * from Department
create table Employee(
emp_no int,
emp_fname varchar(50),
emp_lname varchar(50),
dept_no varchar(20)
)
insert into Employee values(25348,'Matthew','Smith','d3')
insert into Employee values(10102,'Ann','Jones','d3')
insert into Employee values(18316,'John','Barrimore','d1')
insert into Employee values(29346,'James','James','d2')
insert into Employee values(9031,'Elsa','Bertoni','d2')
insert into Employee values(2581,'Elke','Hansel','d2')
insert into Employee values(28559,'Sybill','Moser','d1')
--project table
create table project(
project_no varchar(20),
project_name varchar(20),
budget int
)
insert into project values('p1','Apollo',120000)
insert into project values('p2','Gemini',95000)
insert into project values('p3','Mercury',185600)
select * from project
--the workson
table
create table TheWorks_onTable(
emp_no int,
project_no varchar(50),
job varchar(50),
enter_date datetime
)
insert into TheWorks_onTable values(10102,'p1','Analyst',2006/10/1)
insert into TheWorks_onTable values(10102,'p3','Manager',2008/01/01),(25348,'p2','Clerk',2007/02/15),(18316,'p2',null,2007/06/01)
insert into TheWorks_onTable values(29346,'p2',null,2006/12/15)
insert into TheWorks_onTable values(2581,'p3','Analyst',2007/10/15)
insert into TheWorks_onTable values(9031,'p1','Manager',2007/04/15)
insert into TheWorks_onTable values(28559,'p1','Analyst',2006/10/01)
insert into TheWorks_onTable values(28559,'p2','Clerk',2008/02/01)
insert into TheWorks_onTable values(9031,'p3','Clerk',2006/11/15)
insert into TheWorks_onTable values(29346,'p1','Clerk',2007/01/04)
select * from
TheWorks_onTable
No comments:
Post a Comment