标签:val where desc iss sele dep char group evel
#创建job_grades表
/*CREATE TABLE job_grades
(grade_level VARCHAR(3),
lowest_sal int,
highest_sal int);
INSERT INTO job_grades
VALUES (‘A‘, 1000, 2999);
INSERT INTO job_grades
VALUES (‘B‘, 3000, 5999);
INSERT INTO job_grades
VALUES(‘C‘, 6000, 9999);
INSERT INTO job_grades
VALUES(‘D‘, 10000, 14999);
INSERT INTO job_grades
VALUES(‘E‘, 15000, 24999);
INSERT INTO job_grades
VALUES(‘F‘, 25000, 40000);*/
#查询员工工资和工资级别
SELECT
salary,grade_level
FROM
employees e,job_grades j
WHERE
salary BETWEEN j.`lowest_sal`AND j.`highest_sal` ;
#查询有奖金的每个部门的部门名字和部门的领导编号和该部门的最低工资
SELECT
department_name,d.manager_id,MIN(salary)
FROM
departments d,employees e
WHERE
d.department_id=e.`department_id`
AND `commission_pct` IS NOT NULL
GROUP BY department_name,d.manager_id;
#查询每个工种的工种名和员工的个数,并且按员工个数降序
SELECT
COUNT(*),j.`job_title`
FROM
jobs j,employees e
WHERE
j.`job_id`=e.`job_id`
GROUP BY j.`job_title`
ORDER BY COUNT(*) DESC;
标签:val where desc iss sele dep char group evel
原文地址:https://www.cnblogs.com/Dasnl/p/14651282.html