❶ 怎么在MYsql查询学生平均成绩及其名次
工具/材料:Management Studio。
1、首先在桌面上,点击“Management Studio”图标。
❷ 怎样编写SQL语句求平均成绩
1、打开数据库软件,附加数据库,右键选择新建查询。
❸ sql查询某个学生的平均成绩的排名
1
2
3
4
5
6
7
8
9
10
11
select s.dname,s.sname,s.avggrade
from
(select t.dname,t.sname,t.avggrade,row_number() over (partition by t.dname order by t.avggrade desc) rn
from
(select a.name dname,b.name sname,avg(c.grade) avggrade
from
department a,student b,takes c
where a.department_id=b.department_id
and b.student_id=c.student_id
group by a.name,b.name) t) s
where s.rn=1
包含并列的情况,如果一个学院有两个第一,两个人都显示,以上为 sqlserver或oracle写法,其他数据库执行不了
-------------补充-----------
给你个通用的
select s2.*
from
(select t.dname,max(t.avggrade) avggrade
from
(select a.name dname,b.name sname,avg(c.grade) avggrade
from
department a,student b,takes c
where a.department_id=b.department_id
and b.student_id=c.student_id
group by a.name,b.name) t
group by t.dname) s1,
(select a.name dname,b.name sname,avg(c.grade) avggrade
from
department a,student b,takes c
where a.department_id=b.department_id
and b.student_id=c.student_id
group by a.name,b.name) s2
where s1.dname=s2.dname
and s1.avggrade=s2.avggrade
❹ SQL语句查询每个学生的学号、姓名、平均成绩、最高成绩和最低成绩
select 学生表.学号,学生表.姓名,
average(成绩表.成绩) as 平均成绩,
max(成绩表.成绩) as 最高成绩,
min(成绩表.成绩) as 最低成绩
from 学生表 left join 成绩表 on 学生表.学号=成绩表.学号
order by 学生表.学号
成绩表可换成语文、数学、英语等,查询结果就是各个学生相应课程的平均成绩、历史最高成绩、历史最低成绩.
❺ 怎么用SQL语句查找学生的成绩排名
工具/材料:以Management Studio为例。
1、首先在桌面上,点击“Management Studio”图标。
❻ 查询每位同学的课程门数、总成绩、平均成绩”的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
❼ 如何用sql语句实现成绩求平均分,名次
1:使用sql自带的avg函数
语法:SELECT AVG(column_name) FROM table_name
2:使用sum和count函数进行
SELECT SUM(fJE)/COUNT(*) as column_name FROM table_name
需要条件和分组可在后面加where 条件以及group by 分组
❽ 用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;