日期:2014-05-17 浏览次数:20434 次
--1.
select 学号
from
(
select s.学号,
case when max(case when c.课程名称 = '英语' then s.成绩 else 0 end) >
max(case when c.课程名称 = '数学' then s.成绩 else 0 end)
then 1
else 0
end as flag
from score s
inner join Course c
on s.课程代码 = c.课程代码
where c.课程名称 in ('英语','数学')
group by s.学号
)a
where a.flag = 1
--2.
select st.学号,
st.姓名,
avg(成绩) as 平均成绩
from score s
inner join Student st
on s.学号 = st.学号
group by st.学号,
st.姓名
having avg(成绩) > 60
--3.
select st.学号,
st.姓名,
count(*) as 选课数,
sum(成绩) as 总成绩
from score s
inner join Student st
on s.学号 = st.学号
group by st.学号,
st.姓名
--4.
select st.学号,
st.姓名
from Student st
where not exists(select 1
from score s
inner join Course c
on c.课程代码 = s.课程代码
inner join Teacher t
&nbs