1、首先在sql软件附加有成绩表的数据库,然后右键新建查询。
2、然后用sql语句选中成绩表,命令为update 成绩表。
3、接着用set给成绩一列增加分数,命令为set 成绩=成绩+2。
4、然后要是要选定一个加分的范围,命令为where 成绩>90。
5、最后要是要为身高增加数值的话,就要用到两个表。命令为update 学生表,set 身高=身高+2,where 学号 in(),如下图所示就完成了。
可以使用以下 SQL 语句来查询 score 表中语文成绩的最高分:SELECT MAX(chinese) FROM score;
在这个 SQL 语句中,我们使用了 MAX 函数来查询 chinese 列中的最高分。
你可能需要根据自己的情况来修改表名和列名,以适应你的数据库结构。
1、查询每个学生的各科成绩sql语句:
select astudentid,aname,asex,v1score as '语文',v2score as '数学', v3score as '英语',v4score
as ‘哲学’, (v1score+v2score+v3score+v4score)/4 as ‘平均成绩’ from Stuednt a
left join
(select studentid,score from grade where cid=(select cid from course where cname='语文'))as v1
on astudentid=v1studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='数学'))as v2
on astudentid=v2studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='英语'))as v3
on astudentid=v3studentid
left join
(select studentid,score from grade where cid=(select cid from course where cname='哲学'))as v4
on astudentid=v4studentid
order by astudentid
2、sql数据库介绍:
(1)SQL是Structured Query Language(结构化查询语言)的缩写。SQL是专为数据库而建立的 *** 作命令集,是一种功能齐全的数据库语言。在使用它时,只需要发出"做什么"的命令,"怎么做"是不用使用者考虑的。
(2)SQL功能强大、简单易学、使用方便,已经成为了数据库 *** 作的基础,并且现在几乎所有的数据库均支持SQL。
(3)SQL数据库的数据体系结构基本上是三级结构,但使用术语与传统关系模型术语不同。
(4)在SQL中,关系模式(模式)称为"基本表"(base table);存储模式(内模式)称为"存储文件"(stored file);子模式(外模式)称为"视图"(view);元组称为"行"(row);属性称为"列"(column)。
1创建数据表格create table score(
student_id varchar(10),
score number(10)
)
2插入数据
insert into score values('zhangsan1',59);
insert into score values('zhangsan2',60);
insert into score values('zhangsan3',67);
insert into score values('zhangsan4',71);
insert into score values('zhangsan5',85);
insert into score values('zhangsan6',91);
insert into score values('zhangsan7',null);
3按等级查询成绩,null为未考试
select student_id,score,
case when score<60 then '不及格'
else case when score>=60 and score <75 then '及格'
else case when score >= 75 and score < 85 then '良好'
else case when score >=85 then '优秀'
else '未考试'
end
end
end
end
from score
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)