當前位置:首頁 » 編程語言 » 查詢張三的平均成績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