当前位置:首页 » 编程语言 » 查询张三的平均成绩sql
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

查询张三的平均成绩sql

发布时间: 2023-04-28 13:28:01

㈠ 如何用sql语句查询各门课程的平均成绩

创建表:

SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[stuscore]

( [name] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

[subject] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

[score] [int] NULL,

[stuid] [int] NULL)

ON [PRIMARY]

GO

SET ANSI_PADDING OFF

插入数据:

insert into dbo.stuscore values ('张三','数学',89,1);

insert into dbo.stuscore values ('张三','语文',80,1);

insert into dbo.stuscore values ('张三','英语',70,1);

insert into dbo.stuscore values ('李四','数学',90,2);

insert into dbo.stuscore values ('李四','语文',70,2);

insert into dbo.stuscore values ('李四','英语',80,2);

查询结果如下:

列出各门课程的平均成绩:

select subject,AVG(score)平均成绩 from stuscore
group by subject;

㈡ sql 怎么求出个人三科平均分 语文数学英语 学生有10个 用一条语句输出个人3科平均分!

select [姓名],[语文],[数仔余早学],[英语],([语文]+[数念雀学]+[英语])/3.0 from [成绩表] where [姓名毁兆]='张三'

㈢ SQL 查询 问题

select a.Sname '姓名'知含派,b.Cname '老桐课搭贺程名',AVG (c.Grade) '分数' from Student a, course b, sc c where a.Sno=c.Sno and b.Cno=c.Cno group by a.Sname,b.Cname

㈣ Sql每个班级课程平均成绩

1. 一张学生成绩表内SQL查询每个班级每门课程的平均分

select avg(分数) as 平均分, rtrim(cast(sum(case when 分数>=60 then 1 end)/count(*)*100 as char(10)))+'%' as 及格率 from A group by 班级,课程

2. sql题 查询每位同学的课程门数、总成绩、平均成绩”的SQL语句是什么

selectavg(成绩字段)平均成绩,sum(成绩字段)总成绩,count(课程字段)课程门数from表groupby学生字段;
3. 如何用SQL语句查询各门课程的平均成绩

创建表:

SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[stuscore]

( [name] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

[subject] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,

[score] [int] NULL,

[stuid] [int] NULL)

ON [PRIMARY]

GO

SET ANSI_PADDING OFF

插入数据:

insert into dbo.stuscore values ('张三','数学',89,1);

insert into dbo.stuscore values ('张三','语文',80,1);

insert into dbo.stuscore values ('张三','英语',70,1);

insert into dbo.stuscore values ('李四','数学',90,2);

insert into dbo.stuscore values ('李四','语文',70,2);

insert into dbo.stuscore values ('李四','英语',80,2);

查询结果如下:

列出各门课程的平均成绩:

select subject,AVG(score)平均成绩 from stuscore
group by subject;

4. SQL查询语句,要得到每个班每门课程的平均分,以及每个班的人数。如图:

select 班级,avage(语文) as 语文,avage(数学) as 数学,count(*) as 人数 from table groub by 班级

5. sql 查询每个班级每门课程选课人数和平均分

select class,cname,count(sno) as '选课人数',avg(grade) as '平均版分权'
from student a join sc b on a.sno=b.sno join course c on b.cno=c.cno
group by class,cname

6. 查询每位同学的课程门数、总成绩、平均成绩”的SQL语句是什么

SQL语句如下:

SELECT 学号, Count(课程编号) AS 课程总数, Sum(成绩) AS 总分数, Avg(成绩) AS 平均分

FROM 成绩表

GROUP BY 学号;

SQL常用操作语句如下:

选择:select * from table1 where 范围

插入:insert into table1(field1,field2) values(value1,value2)

删除:delete from table1 where 范围

更新:update table1 set field1=value1 where 范围

查找:select * from table1 where field1 like ’%value1%’

排序:select * from table1 order by field1,field2 [desc]

总数:select count as totalcount from table1

求和:select sum(field1) as sumvalue from table1

平均:select avg(field1) as avgvalue from table1

最大:select max(field1) as maxvalue from table1

最小:select min(field1) as minvalue from table1

7. 用SQL查询,某门课程每个班的总平均分(从高到低排列)

SELECT
AVG(数学)from
分数表
group
by
班级
order
by
AVG(数学)DESC
希望是满意答案,急需!!!!!!!!谢谢

8. SQL求每个学生平均成绩

select student.学号,student.姓名, course.课程名,(select avg(sc.成绩版) from sc where sc.学号权=student.学号) as 平均成绩 from student inner join sc on student.学号=sc.学号 inner join course on sc.课程号=course.课程号

9. SQL问题:如何分别给每个班算平均分

select 班级,avg(table.科目1) as 别名 ,avg(table.科目2) as 别名2,...,
from 表名
group by 班级
SQL查询语句,要得到每个班每门课程的平均分,专以及每属个班的人数
select 班级,avage(table.科目) as 别名,avage(科目2) as 别名2,count(*) as 人数 from table groub by 班级

㈤ 求一条sql语句!

我提供的思路如下:

select 成绩 from A a1 where name = '张三' and 成绩
in (select 成绩昌扰 from A a2 where name = '耐肆旦李四')

思路就是外层查询雹银出所有张三的成绩,再在这个集合中通过子查询出李四的成绩来进行筛选,选出来在张三成绩集合中存在且又在李四成绩集合中存在的成绩

㈥ 用sql命令 写出以下各题的命令

三、按要求写出以下各小题的SQL命令
1、使用UPDATE命令计算机每位学生的总成绩。
update xscj set count=fox+sx+english
2、使用SELECT命令查询所有男生的平均成绩。
select xh,count/3 as 平均成绩 from xscj where xh in( select xh from xs where xb='男')
3、使用INSERT命令向表XS插入一条记录,对应字段的值分别为:“090213”、“张三”、“男”、{^1989-09-01}、“共青团员”、120。
insert into xs values("090213","张三","男",{^1989-09-01},"共青团员",120)
4、使用SELECT命令对表XSCJ的总成绩字段进行升序排序。
select * from xscj order by count asc
5、使用SELECT命令对表XS按性别分组。
select * from xs group by xb
6、使用SELECT命令查询总成绩大于400分的学生的学号、姓名、性别以及总成绩,并将查询结果保存到数据表TEMP中。
select xh,xm,xb,count from xs,xscj where xs.xh=xscj.xh and count>400 into table temp
四、设XS表中已输入了若干条记录,请写出完成如下操作的VFP命令。
1、将表中第3至5条记录的出生日期(CSRQ)都增加三天
use xs
go 3
replace next 3 csrq with csrq+3
2、给表中最后5条记录中总学分低于30的记录加上删除标记
use xs
go reccount()-4
delete next 5 for zxf<30
3、以学号(XH)为关键字为表创建普通索引XH.CDX,并将其设为主控索引
use xs
index on xh tag xh of xh
set order to tag xh
4、用物理删除姓名为“刘燕”的记录
use xs
delete for xm='刘燕'
pack
5、给表中第3条记录后添加一条空白记录
use xs
go 3
insert blank
6、查看表中第3至8号记录的姓名、总学分
use xs
go 3
list next 6 fields xm,zxf

㈦ 1查询成绩表的总分数,平均分,最低分和最高分。用sql语句怎么写

---1. 计算每个人的总成绩并排名(要求显示字段:姓名,总成绩)
select name,sum(cast(score as bigint)) as allscore from stuscore group by name order by allscore desc
---2. 计算每个人的总成绩并排名(要求显示字段: 学号,姓名,总成绩)
select stuid,name,sum(cast(score as bigint)) as allscore from stuscore group by stuid,name order by allscore desc
---3. 计算每个人单科的最高成绩(要求显示字段: 学号,姓名,课程,最高成绩)
SELECT t1.stuid,t1.name,t1.subject,t1.score from stuscore t1,(SELECT stuid,max(score) as maxscore from stuscore group by stuid) t2 where t1.stuid=t2.stuid and t1.score=t2.maxscore
---4. 计算每个人的平均成绩(要求显示字段: 学号,姓名,平均成绩)
select distinct t1.stuid,t1.name,t2.avgscore from stuscore t1,(select stuid,avg(cast(score as bigint)) as avgscore from stuscore group by stuid) t2 where t1.stuid=t2.stuid
---5. 列出各门课程成绩最好的学生(要求显示字段: 学号,姓名,科目,成绩)
select t1.stuid,t1.name,t1.subject,t2.maxscore from stuscore t1,(select subject,max(score) as maxscore from stuscore group by subject) t2 where t1.subject=t2.subject and t1.score=t2.maxscore
---6. 列出各门课程成绩最好的两位学生(要求显示字段: 学号,姓名,科目,成绩)
select distinct t1.* from stuscore t1 where t1.stuid in(select top 2 stuscore.stuid from stuscore where subject = t1.subject order by score desc)order by t1.subject
---7. 统计报表(要求显示字段: 学号,姓名,各科成绩,总分,平均成绩)
select stuid as 学号,name as 姓名,sum(case when subject='语文' then score else 0 end) as 语文,sum(case when subject='数学' then score else 0 end) as 数学,sum(case when subject='英语' then score else 0 end) as 英语,sum(cast(score as bigint)) as 总分,(sum(cast(score as bigint))/count(*)) as 平均分 from stuscore group by stuid,name order by 总分 desc
---8. 列出各门课程的平均成绩(要求显示字段:课程,平均成绩)
select subject,avg(cast(score as bigint)) as avgscore from stuscore group by subject
---9. 列出数学成绩的排名(要求显示字段:学号,姓名,成绩,排名)
select * from stuscore where subject ='数学' order by score desc
---10. 列出数学成绩在2-3名的学生(要求显示字段:学号,姓名,科目,成绩)
select t3.* from(select top 2 t2.* from (select top 3 name,subject,score,stuid from stuscore where subject='数学' order by score desc) t2 order by t2.score) t3 order by t3.score desc
---11. 求出李四的数学成绩的排名
declare @tmp table(pm int,name varchar(50),score int,stuid int)
insert into @tmp select null,name,score,stuid from stuscore where subject='数学' order by score desc
declare @id int
set @id=0;
update @tmp set @id=@id+1,pm=@id
select * from @tmp where name='李四'
---12. 统计各科目及格人数
select subject,
(select count(*) from stuscore where score<60 and subject=t1.subject) as 不及格,
(select count(*) from stuscore where score between 60 and 80 and subject=t1.subject) as 良,
(select count(*) from stuscore where score >80 and subject=t1.subject) as 优
from stuscore t1 group by subject
---13.统计如下:数学:张三(50分),李四(90分),王五(90分),赵六(76分)
declare @s varchar(1000)
set @s=''
select @s =@s+','+name+'('+convert(varchar(10),score)+'分)' from stuscore where subject='数学'
set @s=stuff(@s,1,1,'')
print '数学:'+@s

㈧ asp:查询每个学生的各科成绩,总分,平均分的sql语句

dim rs,sql,sql2,zt,ck,nf,xq,cx,bj,bjmc,info

nf="2016"
xq="春季学期"
cx="期中考试"
bjmc="小学2012级3班"
set rs=server.CreateObject("Adodb.Recordset")
sql="select zuohao,name,xjh,"
sql=sql&"sum(case when xueke='语文' then score else 0 end) as yuwen,"
sql=sql&"sum(case when xueke='数学' then score else 0 end) as shuxue,"
sql=sql&"sum(case when xueke='英语' then score else 0 end) as yingyu,"
sql=sql&"sum(case when xueke='综合' then score else 0 end) as zhonghe,"
sql=sql&"汪告弊sum(score) as zongfen,"
sql=sql&"sum(score)*1.0/4 as pjf"
sql=sql&" from score where nianfen='"&nf&"' and xueqi='"&xq&"'困族 and cixu='"&cx&"' and bjmc='"&bjmc&"友蚂' group by zuohao,name,xjh order by zongfen desc "
rs.open sql,conn,1,1

㈨ sql 语句计算学生总成绩

select
学生.学号
as
姓名,
sum(成绩.分数)
as
总分
from
学生
left
join
成绩
on
成绩.学号=学生.学号
group
by
学生.学号
完全手打,若有疑问直接留言,我会持续关注的,保证好评率~

㈩ 5道SQL的查询语句

假设以上纯启橘表名字做团为“成绩表”

1) SELECT 成绩表.名字,成绩表.科目,成绩表.成绩
FROM 成绩表 INNER JOIN
(SELECT 科目,MAX(成绩) AS 最高分
FROM 成绩表
GROUP BY 科目) 成绩表2 ON 成绩表.成绩=成绩表2.最高分 AND 成绩表.科目=成绩表2.科目

2)
SELECT 名字,科目,成绩
FROM 成绩表
WHERE 成绩<60
ORDER BY 名字,科目

3)
SELECT TOP 3 名字,科目,成绩
FROM 成绩表
WHERE 科目=N'科目名称'旁派
ORDER BY 成绩 DESC

4)
SELECT TOP 3 名字,SUM(成绩) AS 总成绩
FROM 成绩表
GROUP BY 名字
ORDER BY SUM(成绩) DESC

5)
SELECT 名字,AVG(成绩)
FROM 成绩表
GROUP BY 名字
HAVING AVG(成绩)<60