-- 分组统计
select course_id, round(avg(grade),2)
-- round保留小数点后两位
from s_c
group by course_id
-- having avg(grade)>=80
-- 合并 数据的并 UNION ALL -不去重 /UNION -去重复
-- 联接 可能数据都会发生变化 列融在一起
-- 交 intersect
-- 差 minus / except
select * from student where s_sex='男';
UNION ALL
select * from student where s_borndate>='1994-1-1';
-- 并运算可以用或运算 交运算可以用and 差运算可以用not in
select * from student where s_sex='男' or s_borndate>='1994-1-1';
(select * from student where s_sex='男' )
union
(select * from student where s_borndate>='1994-1-1' )
-- order by 放在最后 不然会失效
order by s_name desc;
1992
-- s_id两个表里都有,所以要在s_id前面加上表名.后面那三个都是唯一的
select a.s_id,s_name,c.course_id,course_name,grade
from student a ,s_c b,course c
where a.s_id=b.s_id and b.course_id=c.course_id