Ⅰ sql怎麼求男女學生平均成績
select a.性別,AVG(B.成績) as 平均成績 from 人員信息表 a join 學生成績表 b on a.id=b.id
大概是這么樣的寫法,你看看你的人員信息表和成績表關聯條件是什麼樣的,
Ⅱ 資料庫中用SQL語言分別求男女的平均成績,要求包含成績和性別欄位,在線等!
應該是這樣吧:
select 性別,avg(英語) as 平均成績 form zgk group by 性別;
Ⅲ 編寫Sql,查詢學生表中分數大於等於60的學生信息並按照性別分組自以及分數降序
摘要 前面1~5都比較簡單,我就單說問題6:
Ⅳ 用sql語言按性別統計出語文和數學至少一門不及格的學生人數
select 性別,count(*) 人數 from table where 語文<60 or 數學<60
group by 性別
Ⅳ mysql如何用一條sql查詢一個班6個人,男生成績總數和女生成績總數。
select(SELECTSUM(成績)FROM`student`wheresex='男')asa,(SELECTsum(成績)fromstudentWHEREsex='女')asb;
Ⅵ sql語句,表連接。用sql語句按男女分類統計各科的總成績和平均成績
建議你先創建個視圖。 create view xs_cj as ( select xs.xm,xs.xb,xs.rxsj,cj.xyw,cj.sx,cj.yy from xs inner join cj on xs.xm=cj.xm ); 然後查詢: select xb, sum(yw) 'sum(yw)',sum(sx)'sum(sx)',sum(yy) 'sum(yy)', avg(yw) 'avg(yw)',avg(sx)'avg(sx)',avg(yy) 'avg(yy)' from xs_cj group by xb ;
Ⅶ SQL語句怎麼分別統計男女數學英語成績平均分
selectavg(數學成績),avg(英語成績)fromstudentgroupby性別
Ⅷ 寫出Tansact-SQL語句,按性別統計表stu_info中的人數及平均成績
select
性別,count(*)
as
人數,avg(成績)
as
平均成績
from
sut_info
group
by
性別
性別,成績那倆欄位,你替換成你表裡相應的名稱就好
Ⅸ sql 語言 統計不同性別學生的人數,入學成績最高,最低,平均分
sql 查詢最高分、最低分和平均分語句
//我們要用就以學生成績為實例吧
/*
結構
學生表
Student(S#,Sname,Sage,Ssex) --S# 學生編號,Sname 學生姓名,Sage 出生年月,Ssex 學生性別
--2.課程表
Course(C#,Cname,T#) --C# --課程編號,Cname 課程名稱,T# 教師編號
*/
查詢各科成績最高分、最低分和平均分:以如下形式顯示:課程ID,課程name,最高分,最低分,平均分,及格率,中等率,優良率,優秀率
--及格為>=60,中等為:70-80,優良為:80-90,優秀為:>=90
--方法1
select m.C# [課程編號], m.Cname [課程名稱],
max(n.score) [最高分],
min(n.score) [最低分],
cast(avg(n.score) as decimal(18,2)) [平均分],
cast((select count(1) from SC where C# = m.C# and score >= 60)*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [及格率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 70 and score < 80 )*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [中等率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 80 and score < 90 )*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [優良率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 90)*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [優秀率(%)]
from Course m , SC n
where m.C# = n.C#
group by m.C# , m.Cname
order by m.C#
--方法2
select m.C# [課程編號], m.Cname [課程名稱],
(select max(score) from SC where C# = m.C#) [最高分],
(select min(score) from SC where C# = m.C#) [最低分],
(select cast(avg(score) as decimal(18,2)) from SC where C# = m.C#) [平均分],
cast((select count(1) from SC where C# = m.C# and score >= 60)*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [及格率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 70 and score < 80 )*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [中等率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 80 and score < 90 )*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [優良率(%)],
cast((select count(1) from SC where C# = m.C# and score >= 90)*100.0 / (select count(1) from SC where C# = m.C#) as decimal(18,2)) [優秀率(%)]
from Course m
order by m.C#
Ⅹ 查詢學生檔案中的學生總數入學成績的平均值,按性別分類怎麼寫sql查詢語句
你好,很高興回答你的問題。
類似這樣的問題,不同的表結構對應的查詢語句是不同的,所以先提供一下表結構吧,大家才好依據表結構幫你解決問題。