rkday1/one.sql

43 lines
1.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`eid` int(11) NOT NULL AUTO_INCREMENT,
`ename` varchar(255) ,
`sex` varchar(255) ,
`tel` varchar(255) ,
`classid` int(11) ,
`age` int(11) ,
`sal` double(50, 2) ,
PRIMARY KEY (`eid`) USING BTREE
)
INSERT INTO `student` VALUES (1, '雷秀英', '', '13026334953', 18, 28, 2112.12);
INSERT INTO `student` VALUES (2, '苏璐', '', '15329043438', 29, 26, 3147.94);
INSERT INTO `student` VALUES (3, '高安琪', '', '15780675303', 19, 22, 6887.02);
INSERT INTO `student` VALUES (4, '赵子异', '', '16847806488', 24, 25, 1134.34);
INSERT INTO `student` VALUES (5, '谭子韬', '', '7604828155', 15, 29, 4218.50);
-- 2.查询所有学生信息并根据年龄进行降序排序。10分
SELECT * FROM `student` ORDER BY age DESC
-- 3.显示姓王的学生的详细信息。10分
SELECT * FROM `student` where ename LIKE "王%"
-- 4.查询工资大于5000的所有男同学的信息。10分
SELECT * FROM `student` where sal >5000 AND sex =""
-- 5.查询班级编号为20的男同学的电话号码。10分
SELECT ename,tel FROM `student` where classid=20 AND sex =""
-- 6.查询最低工资。10分
SELECT MIN(sal) FROM `student`
-- 7.查询班级为30的学生的最小年龄。10分
SELECT MIN(age) FROM `student` where classid=30
-- 8.查询女生的最低工资。15分
SELECT MIN(sal) FROM `student` where sex=""
-- 9.查询女学生中薪资最低的人的全部信息。15分
SELECT *,MIN(sal) FROM `student` where sex=""