查詢每位學生選課數和總成績
⑴ 查詢每位同學的課程門數、總成績、平均成績」的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
⑵ 查詢每位學生的學號姓名選課的課程號成績,資料庫語言
select
t.sno,sname,avg(grade)
as
平均分,count(cname)
as
選課門數
from
student
t,sc
c,course
e
where
t.sno=c.sno
and
c.cno=e.cno
and
t.sno=
(select
top
1
t1.sno
from
student
t1,sc
c1,course
e1
where
t1.sno=c1.sno
and
c1.cno=e1.cno
and
e1.cname='數據結構'
order
by
c1.grade
desc)
group
by
t.sno,sname
1.
先用子查詢
查出課程最高分的同學的學號
2.
再根據學專號得到平均分agv和選屬課門數
count
⑶ 求寫出SQL查詢oracle資料庫學生表裡的每個班級每個課程的總成績
selectcourseas'成績總和',
sum(casewhenclass='JSD1701'thenscoreelse0end)as'jsd1701',
sum(casewhenclass='JSD1702'thenscoreelse0end)as'jsd1702',
sum(casewhenclass='JSD1703'thenscoreelse0end)as'jsd1703',
sum(casewhenclass='JSD1704'thenscoreelse0end)as'jsd1704'
fromclass_score_sumgroupbycourse;
⑷ SQL一個查詢中包含兩個聚集函數怎麼弄啊例如,查詢每名學生的選課門數和平均成績怎麼弄啊
SELECT
Student.Sname,
COUNT(distinct Course.Cno) AS 選課門數,
AVG(Sc.Grade) AS 平均成績
FROM
SC
JOIN Student ON (SC.Sno = Student.Sno)
JOIN Course ON (SC.Cno = Course.Cno)
GROUP BY
Student.Sname
Sname 選課門數 平均成績
---------- ----------- -----------
李勇 3 88
劉晨 2 72
錢小平 2 87
王大力 1 85
吳賓 4 74
張海 2 68
警告: 聚合或其他 SET 操作消除了空值。
-----
SELECT
Student.Sname,
COUNT(distinct Course.Cno) AS 選課門數,
AVG(Sc.Grade) AS 平均成績
FROM
SC
JOIN Student ON (SC.Sno = Student.Sno)
JOIN Course ON (SC.Cno = Course.Cno)
GROUP BY
Student.Sname
HAVING
COUNT(distinct Course.Cno) >= 4
Sname 選課門數 平均成績
---------- ----------- -----------
吳賓 4 74
警告: 聚合或其他 SET 操作消除了空值。
⑸ sql:查詢所有學生的學號、姓名、入學成績、選課門數和平均分。結果要求顯示如下
Select SId,SName,sgrade 入學成績抄, (Select Count(CId) From score Where SId=s.SId)選課門數, (Select avg(grade) From score Where SId=s.SId)平均分
From Student s;
其中sid是學號,cid是課程號。
⑹ SQL 統計每個學生的選課門數和考試總成績,求各位大大指教
selecta.姓名.count(c.課程抄號襲)as選課門數,sum(c.成績)as總成績from學生表a,課程表b,成績表cwherea.學號=c.學號andb.課程號=c.課程號groupbya.姓名
⑺ 從教學庫中查詢每個學生的學號、選課門數和平時成績,寫出SQL語句
這個應該涉及到三個表吧
select 學生表.學號,count(課程.科目) as 選課內門數,成績表容.平時成績 from 學生表,課程表,成績表 where 學生表.學號=課程表.學號 and 課程表.課程號=成績表.課程號
⑻ 統計每個學生的選課門數和考試總成績,並按選課門數的降序排列
select
課程,
count(課程編號)
as
選課人數
,
avg(成績)
as
平均成績
from
表
group
by
課程編號
⑼ access中建立一個查詢,查詢學生和選課成績為數據源計算每班的平均成績
同上.估計你是多打了引號.......
原句的語法沒有問題,但建議以後用「點」號: 班級:Left([學生].[學生編號],8) 這種寫法較通用。
⑽ sql題 查詢每位同學的課程門數、總成績、平均成績」的SQL語句是什麼
selectavg(成績欄位)平均成績,sum(成績欄位)總成績,count(課程欄位)課程門數from表groupby學生欄位;