Auto commit
This commit is contained in:
parent
d2970d183d
commit
86d4341146
@ -179,6 +179,79 @@ VALUES
|
||||
|
||||

|
||||
|
||||
```sql
|
||||
#5
|
||||
SELECT e.empid, e.`name`, e.title, d.depname, s.basesalary + s.titleSalary, s.basesalary + s.titleSalary-IFNULL(s.decuction, 0)
|
||||
FROM employee e, department d, salary s
|
||||
WHERE e.depid = d.depid AND e.empid = s.empid;
|
||||
#6
|
||||
SELECT e.`name`, s.basesalary
|
||||
FROM employee e, department d, salary s
|
||||
WHERE e.depid = d.depid AND e.empid = s.empid AND d.depname = '销售部';
|
||||
#7
|
||||
SELECT *
|
||||
FROM employee e
|
||||
WHERe e.`name` LIKE '张%' AND TIMESTAMPDIFF(YEAR,e.birthday, NOW()) < 40;
|
||||
#8
|
||||
SELECT e.`name`, s.basesalary, s.titleSalary
|
||||
FROM employee e, salary s
|
||||
WHERE e.sex = '男' AND e.empid AND s.empid;
|
||||
#9
|
||||
SELECT e.`name`, e.title, d.depname
|
||||
FROM employee e, department d, salary s
|
||||
WHERE e.depid = d.depid AND e.empid = s.empid AND s.basesalary < 2000;
|
||||
#10
|
||||
SELECT COUNT(*)
|
||||
FROM employee;
|
||||
#11
|
||||
SELECT COUNT(*)
|
||||
FROM department d;
|
||||
#12
|
||||
SELECT AVG(s.basesalary + s.titleSalary), MAX(s.basesalary + s.titleSalary), MIN(s.basesalary + s.titleSalary)
|
||||
FROM employee e, salary s
|
||||
WHERE e.empid = s.empid;
|
||||
#13
|
||||
SELECT d.depname, AVG(s.basesalary + s.titleSalary)
|
||||
FROM employee e, salary s, department d
|
||||
WHERE e.empid = s.empid AND e.depid = d.depid
|
||||
GROUP BY d.depid;
|
||||
#14
|
||||
SELECT d.depname, AVG(s.basesalary + s.titleSalary) avg
|
||||
FROM employee e, salary s, department d
|
||||
WHERE e.empid = s.empid AND e.depid = d.depid
|
||||
GROUP BY d.depid
|
||||
HAVING avg<2000;
|
||||
#15
|
||||
SELECT e.empid, e.`name`, s.basesalary, s.titleSalary, s.decuction
|
||||
FROM employee e, salary s, department d
|
||||
WHERE e.empid = s.empid AND e.depid = d.depid
|
||||
ORDER BY s.titleSalary, s.basesalary;
|
||||
#16
|
||||
SELECT e.empid, e.`name`, e.birthday,
|
||||
IF(YEAR(e.birthday) < 1980, '老年',
|
||||
IF(YEAR(e.birthday)< 1990, '中年', '青壮年'))
|
||||
FROM employee e;
|
||||
#17
|
||||
SELECT e.*, depname
|
||||
FROM employee e, department d
|
||||
WHERE e.depid = d.depid;
|
||||
#18
|
||||
SELECT d.*, e.*
|
||||
FROM employee e, department d
|
||||
WHERE e.depid = d.depid;
|
||||
#19
|
||||
SELECT *
|
||||
FROM employee e
|
||||
WHERE e.title LIKE '%工程师%' AND e.sex = '男';
|
||||
#20
|
||||
SELECT d.depname, e.sex, COUNT(*), AVG(s.basesalary)
|
||||
FROM employee e, department d, salary s
|
||||
WHERE e.depid = d.depid AND e.empid = s.empid
|
||||
GROUP BY d.depid, e.sex;
|
||||
```
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
### 练习四
|
||||
|
Loading…
x
Reference in New Issue
Block a user