1. Create a table EMPLOY, the fields in the table are as shown in the figure below:
create table EMPLOY
(
EMPNO INT PRIMARY KEY,
ENAME VARCHAR(10),
JOB VARCHAR(9),
MGB INT,
HIREDATE DATE,
SAL DOUBLE,
COMM DOUBLE,
DEPTNO INT
);
2. Insert the following data into the table:
INSERT INTO EMPLOY VALUES
(7369,'SMITH','职员',7566,"1980-12-17",800,NULL,20),
(7499,'ALLEN','销售员',7698,"1981-02-20",1600,300,30),
(7521,'WARD','销售员',7698,"1981-02-22",1250,500,30),
(7566,'JONES','经理',7839,"1981-04-02",2975,NULL,20),
(7654,'MARTIN','销售员',7698,"1981-09-28",1250,1400,30),
(7698,'BLANK','经理',7839,"1981-05-01",2850,NULL,30),
(7782,'CLARK','经理',7839,"1981-06-09",2450,NULL,10),
(7788,'SCOTT','职员',7566,"1987-07-03",3000,2000,20),
(7839,'KING','董事长',NULL,"1981-11-17",5000,NULL,10);
3. Complete the following query:
(1) Find the detailed information of the employee whose department is 30.
select * from EMPLOY WHERE DEPTNO=30;
(2) Find out the number, name, and department number of the employee engaged in the work of the employee.
select EMPNO,ENAME,DEPTNO from EMPLOY WHERE JOB IN('职员');
(3) Retrieve information about employees whose bonuses are more than their basic salary.
select * from EMPLOY where COMM>SAL;
(4) Retrieve information about employees whose bonuses are more than 60% of their basic salary.
select * from EMPLOY where COMM>SAL*0.6;
(5) Find out the information of the employee whose name contains A.
select * from EMPLOY where ENAME LIKE '%A%';
(6) Find out the information of employees whose names start with A, B, and S.
select * from EMPLOY where ENAME LIKE 'A%' OR ENAME LIKE 'B%' OR ENAME LIKE 'S%';
(7) Find employee information whose name is 7 characters long.
select * from EMPLOY where ENAME LIKE '_______';
(8) Query employees who have no bonus or bonuses less than 1000.
select * from EMPLOY where COMM IS NULL OR COMM<1000;
(9) Query employees who joined in 2000
select * from EMPLOY where HIREDATE>='2000-1-1' AND HIREDATE<='2000-12-31';