|
本帖最后由 拿不动25 于 2018-8-31 15:08 编辑
---第一题
select
st.stu_name,
class_id ,
lession_name
from
t_lession le,
t_stu_profile st
where
le.lession_id not in
(
select lession_id from t_score sc where sc.stu_id = st.stu_id
)
order by
1,3;
---第二题
select * from (
select
le.lession_name,
st.stu_name,
rank() over (partition by le.lession_name order by score desc) rk ,
score
from
t_lession le,
t_score sc ,
t_stu_profile st
where
le.lession_id = sc.lession_id
and sc.stu_id = st.stu_id) as p
pivot (max(stu_name || '+' ||score) for p.rk in (1 as "第一名",2 as "第二名",3 as "第三名") ) as t;
---第三题
select * from (
select stu_name,lession_name,score, sum(score) over(partition by sc.stu_id) as "总分"
from T_STU_PROFILE stu,T_SCORE sc,T_LESSION le
where stu.stu_id = sc.stu_id
and sc.lession_id = le.lession_id
and stu.class_id = '0611') as p
pivot (max(score) for p.lession_name in ('语文', '数学', '英语','物理','化学' ) )
|
|