当前位置:首页 » 编程语言 » sql分数差
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

sql分数差

发布时间: 2023-03-17 11:40:00

‘壹’ sql计算数字差怎么写

建议是编写函数做,不过非要做,也可以做的。
我建立一个测试表:
表名是testsc 就是学生成绩表

SNO Number - - - - - - 学号
CNO Number - - - - - - 课程号
GRADE Number - - - - - - 成绩

然后先建立一个视图,这个视图中求得的是所有同学的平均成绩:
create view testscavg as select t1.sno as sno ,avg(t1.grade) as avggrade from testsc t1 group by t1.sno

然后求出学生平均成绩最高的和最低的之差:
select max(AVGGRADE)-min(AVGGRADE) from testscavg

‘贰’ sql语句如何查询两个值之间的差

工液局具/材料:Management Studio。

1、首先在桌面上闹宽让,点击“Management Studio”图标。

‘叁’ 前十条数据的分数字段的标准差 sql语句怎么写~~~~~~急

对系统的标准差算法有质疑,自己写了个算法,各位看看!
A表有两列id、number
id number
1 1
2 2
---------------------------------------------------
declare @m numeric(30, 20), @n int;
declare @i int, @x numeric(30, 20), @temp numeric(30, 20);
set @n=2;
set @i=0;
set @temp=0;
select @m=AVG(number) from A where id in (select top 2 id from A);
while (@i<2)
begin
if(@i=0)
begin
select @x=number from A where id = (select top 1 id from A where id not in (select top 0 id from A));
set @temp = @temp + power(@x-@m,2);
select @temp;
end
else if (@i=1)
begin
select @x=number from A where id = (select top 1 id from A where id not in (select top 1 id from A));
set @temp = @temp + power(@x-@m,2);
end
set @i = @i+1;
end
set @temp = @temp/@n;
declare @result numeric(30, 20)
set @result = sqrt(@temp);
select @result;
计算前二条数据
结果:0.5
系统函数计算结果:0.707106781186548

‘肆’ SQL在学生表中查询每个人的总分与平均总学分的差,要求显示学号、姓名、专业、总学分、与平均总学分的差

T-SQL语句如下:
Select 学号,姓名,专业,总学分,总学分-(select avg(总学分) from [学生选课系统].[dbo].[学生表] where 专业=A.专业) as 与平均总学分的差 From [学生选课系统].[dbo].[学生表] as A
(*注:以上语句是学生与其所属专业的平均总学分的对比,即平均总学分是按专业分开计算的)

如果不用考虑区分专业,而是直接跟全校学生的平均总学分比较的话,用下面的语句:
Select 学号,姓名,专业,总学分,总学分-(select avg(总学分) from [学生选课系统].[dbo].[学生表]) as 与平均总学分的差 From [学生选课系统].[dbo].[学生表] as A

‘伍’ 用SQL语句显示班级学号成绩并算出优良中差

select 班级,学号,(case when 成绩扰答>90 then '优'
when 成绩>银中80 and 成锋李山绩<=90 then '良'
when 成绩>60 and 成绩<=80 then '中'
else '差' end) as 成绩
from table_name

‘陆’ SQL数据库查询中,怎么查询某一列数据的标准偏差,例如一个班级的学生的成绩的标准偏差

select @avg=avg(列) from 表;
select @num=count(列) from 表;
select @exp= sqrt (sum(square(列-@avg))/(@num-1)) from 表;

print @avg,@num,@exp

其中@avg为列的平均值,@num为列数量,@exp为标准偏差

这种计算性的工作应该又外部程序完成而不是用数据库来完成。

‘柒’ SQL语句,如何求每个学生的成绩与平均成绩的差

不知道你具体什么数据库,,,可以用with as语句

;withcteas(select*
from表)

select*,
成绩核码-(selectavg(成绩)fromtest)改改哪as平均成绩
fromcte歼宴t

‘捌’ 如何用sql语句查出学生表成绩小于60为不及格60-80为良好80-90为优秀

select name,case when 成绩<60 then 不及格 when 成绩>=60 and 成绩<80 then 良好 when 成绩>=0 and 成绩<90 then 优秀 end as 成绩情况 ,from 表名。

注意,在输入sql语句的时候,要在英文环境下输入。否则可能会出现代码不识别。

‘玖’ SQL得到总分最低和总分最高学生的总分差

table
no,course,score
11 3 67

select A-B from table T,(select max(score) from table ) A,(select min(score) from table) B