XJTU_Python/test/7/4.sql

86 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 请根据下方提示,在正确位置填写代码或脚本。
/********** Begin *********/
--1.查询reader表所有信息
select
*
from
reader;
--2.查询专业为medicine的专业的学生的姓名和年龄
select
name,
age
from
reader
where
major = "medicine";
--3.查询读者来自哪些专业,显示不同的专业。
select
DISTINCT major
from
reader;
--4.查询年龄在25岁以上的读者的学号和姓名显示学号和姓名。
select
number,
name
from
reader
where
age > 25;
--5.查询年龄在不超过24岁的学生的学号、姓名和年龄结果按年龄降序排列。
select
number,
name,
age
from
reader
where
age <= 24
order by
age DESC;
--6.查询“信计”专业所有学生的学号、姓名,结果按年龄大小排列。(不显示年龄)。
select
number,
name
from
reader
where
major = "science"
order by
age;
--7.统计学生人数。
select
count(*)
from
reader;
--8.统计所有学生的平均年龄。
select
avg(age)
from
reader;
--9.查询所有学生的最大年龄。
select
max(age)
from
reader;
--10.查询所有学生的最小年龄。
select
min(age)
from
reader;
--11.查询所有学生的最大年龄差。
select
max(age) - min(age)
from
reader;
/********** End *********/