题目

①从学生表当中查询所有数据

②从学生表当中查询学生的姓名、学号、年龄、性别

③从学生表中查询年龄大于18岁的学生

④从学生表中查询年龄大于18岁的女学生

⑤从学生表中查询年龄大于18岁的女学生并且按照年龄降序,班级升序的条件排序

⑥从学生表中查询年龄大于18岁的女学生或者是年龄小于18的男学生;

⑦从学生表中查询学生最大、最小的年龄和学生总数,学生平均年龄

⑧从学生表中查询每个班学生最大、最小的年龄和学生总数,学生平均年龄

⑨从学生表中查询每个班学生最大、最小的年龄和学生总数,学生平均年龄,筛选出班级学生总数大于5的数据结果

⑩从学生表中查询每个班学生最大、最小的年龄和学生总数,学生平均年龄,并且查询结果按照班级排序。

⑪从学生表中查询班级名称和每个班学生最大、最小的年龄和学生总数,学生平均年龄,并且查询结果按照班级排序。

⑫罗列出每个班级的学生信息,按班级排序

⑬查询学生人数大于5个的班级信息,并且按照班级排序


1. SELECT * FROM student;

2. SELECT `Stu_name` AS 姓名,`Stu_code` AS 学号, `Stu_age` AS 年龄 ,`Stu_gender` AS性别 FROM student AS 学生表;

3. SELECT `Stu_age` FROM student

WHERE `Stu_age` >18;

4. SELECT `Stu_age` FROM student

WHERE `Stu_age` >18 and `Stu_gender`=`女`;

5. SELECT `Stu_age` FROM student order by age desc,class asc

WHERE `Stu_age` >18 and `Stu_gender`=`女`;

6. SELECT `Stu_age` FROM student

WHERE `Stu_age` >18 and `Stu_gender`=`女` or

SELECT `Stu_age` FROM student

WHERE `Stu_age` <18 and `Stu_gender`=`男`;

7. SELECT SUM(`Stu_id`) AS 总数 FROM student;

  SELECT AVG(`Stu_age`) AS 平均年龄 FROM student;

  SELECT MAX(`Stu_age`) AS 最大龄 FROM student;

  SELECT MIN(`Stu_age`) AS 最小龄 FROM student;

    8. SELECT MAX (`Stu_age`), MIN (`Stu_age`), SUM(`Stu-age`) ,AVG(`Stu_age) FROM student

    WHERE (SELECT count(class_id) FROM student

            WHERE a.Stu_age=Stu_age);

9.(不会)

10.  SELECT MAX (`Stu_age`), MIN (`Stu_age`), SUM(`Stu-age`) ,AVG(`Stu_age) FROM student order by class_id

    WHERE (SELECT count(*) FROM student

            WHERE a.Stu_age=Stu_age);

11. SELECT `class_name`  AS 班级名称 FROM class AS 班级表 AND (不会)


12. SELECT * FROM student order by class_id

13. SELECT SUM (`student`) FROM clss_name order by class_id

  WHERE SUM (`student`)>5;

你可能感兴趣的:(题目)