sql 面试题

1、编写SQL语句查询出每个各科班分数最高的同学的名字,班级名称,课程名称,分数2、编写一个存储过程,为分数60分以下的同学加5分,分数在60分至80分的同学加2分,分数... 1、编写SQL语句查询出每个各科班分数最高的同学的名字,班级名称,课程名称,分数
2、编写一个存储过程,为分数60分以下的同学加5分,分数在60分至80分的同学加2分,分数80分以上的同学加1分,若有100分则不加分。
展开
 我来答
hemu780924
2009-08-13 · TA获得超过662个赞
知道小有建树答主
回答量:495
采纳率:0%
帮助的人:557万
展开全部
select class.name,student.name,course,score
from class,student,score,(select max(score) max_score ,course,classid from score,student where score.studentid = student.id group by course,classid) tmp
where class.id =student.classid
and student.id = score.studentid
and score.score = tmp.max_score
and score.course =tmp.course
and student.calssid = tmp.classid

CREATE PROCEDURE test
AS
BEGIN

update table_1 set score=score+1 where score>=80 and score<100;
update table_1 set score=score+2 where score>=60 and score<80;
update table_1 set score=score+5 where score<60;

END
GO
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zfy0921
2009-08-13 · 超过56用户采纳过TA的回答
知道小有建树答主
回答量:320
采纳率:0%
帮助的人:151万
展开全部
1、
select studentName,classname,course,score
from score
inner join student
on score.studentid=student.studentid
inner join class
on student.classid=class.classid
where score in
(select max(score)
from score inner join student
on score.studentid = student.studentid
group by classid,course)

2、
create proc proc_scs
AS
begin
update score set score=score+1 where score>=80 and score<100;
update score set score=score+2 where score>=60 and score<80;
update score set score=score+5 where score<60;
end
go
存储过程同三楼
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
a5202003
2009-08-13 · TA获得超过2250个赞
知道大有可为答主
回答量:1885
采纳率:75%
帮助的人:673万
展开全部
select c.classname 班级,e.course 科目,max(e.score) 最高分 from class c,student s,score e where c.classid=s.classid and s.studentid=e.studentid group by c.classname,,e.course

就写到这吧,楼主给的分就值这些了,嘿嘿
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zhao_gw
2009-08-13
知道答主
回答量:15
采纳率:0%
帮助的人:2.4万
展开全部
1、select top 1 名字,班级名称,课程名称,分数 from 班级 order by 分数 desc;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
天马行空9156
2009-08-13 · 超过53用户采纳过TA的回答
知道小有建树答主
回答量:272
采纳率:0%
帮助的人:187万
展开全部
确实很简单,3楼正解。估计这公司开出的待遇也不怎么样。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(6)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式