MySQL每日练习

这篇博客提供了5道关于MySQL的练习题目,包括按照title分组统计、去重计数、奇数工号条件筛选、当前title对应薪水的平均工资计算以及找出当前薪水第二高的员工。内容详细解释了每道题目的解题思路和SQL操作。
摘要由CSDN通过智能技术生成

练习

第1题

从titles表获取按照title进行分组,每组个数大于等于2,给出title以及对应的数目t。

  • 建表
CREATE TABLE IF NOT EXISTS titles (
 emp_no int(11) NOT NULL,
 title varchar(50) NOT NULL,
 from_date date NOT NULL,
   to_date date DEFAULT NULL); 
  • 插入数据
 INSERT INTO titles VALUES(10001,'Senior Engineer','1986-06-26','9999-01-01');
 INSERT INTO titles VALUES(10002,'Staff','1996-08-03','9999-01-01');
 INSERT INTO titles VALUES(10003,'Senior Engineer','1995-12-03','9999-01-01');
 INSERT INTO titles VALUES(10004,'Engineer','1986-12-01','1995-12-01');
 INSERT INTO titles VALUES(10004,'Senior Engineer','1995-12-01','9999-01-01');
 INSERT INTO titles VALUES(10005,'Senior Staff','1996-09-12','9999-01-01');
 INSERT INTO titles VALUES(10005,'Staff','1989-09-12','1996-09-12');
 INSERT INTO titles VALUES(10006,'Senior Engineer','1990-08-05','9999-01-01');
 INSERT INTO titles VALUES(10007,'Senior Staff','1996-02-11','9999-01-01');
 INSERT INTO titles VALUES(10007,'Staff','1989-02-10','1996-02-11');
 INSERT INTO titles VALUES(10008,'Assistant Engineer','1998-03-11','2000-07-31');
 INSERT INTO titles VALUES(10009,'Assistant Engineer','1985-02-18','1990-02-18');
 INSERT INTO titles VALUES(10009,'Engineer','1990-02-18','1995-02-18');
 INSERT INTO t
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值