发布网友 发布时间:2022-04-25 05:41
共3个回答
热心网友 时间:2022-04-14 17:51
select a.studentId,a.name,a.sex,c.cid,b.cname,c.score
into TableA
from Student a, Course b, Grade c
where a.studentId=c.studentId and c.cid=b.cid
select a.studentId,a.name,a.sex,
sum(case cname when "语文" then score else 0 end) as 语文,
sum(case cname when "数学" then score else 0 end) as 数学,
sum(case cname when "英语" then score else 0 end) as 英语,
sum(case cname when "哲学" then score else 0 end) as 哲学,
sum(score)*1.0/4 as "平均成绩"
热心网友 时间:2022-04-14 19:09
\--代码如下--\
SELECT a.sname AS '姓名'
MAX(CASE b.sid WHEN '0001'THEN b.score ELSE 0 END) AS '语文'
MAX(CASE b.sid WHEN '0002'THEN b.score ELSE 0 END) AS '数学'
MAX(CASE b.sid WHEN '0003'THEN b.score ELSE 0 END) AS '英语'
FROM student a,scores b ON a.sid=b.sid
GROUP BY b.sid
热心网友 时间:2022-04-14 20:44
mysql
参照 http://www.cnblogs.com/lhj588/p/3315876.html