其他分享
首页 > 其他分享> > msqyl-

msqyl-

作者:互联网

# 案例6:查询有奖金的每个部门的部门名和部门的领导编号和该部门的最低工资
SELECT
d.`department_name` AS 部门名,d.`manager_id`AS 领导编号, MIN(`salary`)AS 最低工资
FROM `employees`AS e,`departments`AS d
WHERE d.`department_id`=e.`department_id`AND e.`commission_pct` IS NOT NULL;

#案例7;查询每个工种名和员工的个数,并且按员工个数降序
SELECT j.`job_title`AS 工种名,
COUNT(*) AS 员工个数
FROM `employees` AS e , `jobs` AS j
WHERE j.`job_id` = e.`job_id`
GROUP BY j.`job_title`
ORDER BY COUNT(*) DESC;

#8:查询员工名,部门名和所在的城市
SELECT e.`first_name`AS 员工名,
d.`department_name` AS 部门名称,
l.`city` AS 城市
FROM `departments` AS d ,`employees`AS e,`locations`AS l
WHERE d.`department_id`=e.`department_id` AND d.`location_id`=l.`location_id`

#9:查询员工的工资和工资级别
##创建SALGRADE表 插入工资等级数据
/*create table SALGRADE(GRADE varchar(4),LOSAL int,HISAL int);
INSERT INTO SALGRADE VALUES('A',0,2999);
INSERT INTO SALGRADE VALUES('B',3000,5999);
INSERT INTO SALGRADE VALUES('C',6000,11999);
INSERT INTO SALGRADE VALUES('D',12000,19999);
INSERT INTO SALGRADE VALUES('E',20000,24000);*/
SELECT `salary`AS 工资,`GRADE`AS 工资等级
FROM `employees`,`salgrade`

SELECT `GRADE` ,`HISAL`,`LOSAL`
FROM `salgrade`

CREATE TABLE today(st_id INT(4),st_name VARCHAR(4),sex CHAR, PRIMARY KEY(st_id) );

 

 

标签:INSERT,SALGRADE,msqyl,VALUES,department,id,SELECT
来源: https://www.cnblogs.com/x5253/p/15692755.html