當前位置:首頁 » 編程語言 » 在sql中查每門課缺考人數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

在sql中查每門課缺考人數

發布時間: 2023-01-23 19:49:56

sql查詢問題 查詢成績分布情況

呵呵,你這是一堆的問題呀:

優秀、良好……各級別的(人數):
首先,假設你的分數是 百分制,優秀即高於85分等。。。。
因此:

select 課程,count(*) as 人數,『優秀』 as 類別
from 成績
where 分數>85
group by 課程
union
select 課程,count(*) as 人數,『良好』 as 類別
from 成績
where 分數>70 and 分數<=85
group by 課程
union
select 課程,count(*) as 人數,『及格』 as 類別
from 成績
where 分數>60 and 分數<=70
group by 課程

分布情況及百分比:
得根據上面的結果來再計算。
先弄個總人數的視圖:select count(*) as 總人數 from 成績
再計算百分比:
select 課程,人數/總人數*100% as 百分比 from 各級別人數 group by 課程,類別

其他的統計也就雷同了。

㈡ SQL Service數據查詢操作 統計每門課程的選課人數及不及格人數

select c.cnum,
c.cname,
count(1) "選課人數",
sum(case
when sc.score < 60 then
1
else
0
end) "不及格人數"
from course c, sections s, sc
where s.cnum = c.cnum
and sc.secnum = s.secnum
group by c.cnum, c.cname

㈢ SQL查詢 統計每門課的選課人數及不及格人數

select a.cnum,a.cname,a.rs,b.bjg_rs
from

(select sec.cnum,c.cname,count(s.snum) as 'rs'
from student s,course c,sc,sections sec
where s.snum = sc.snum and
sc.secnum = sec.secnum and
sec.cnum = c.cnum
group by sec.cnum,c.cname) a

left join

(select sec.cnum,c.cname,count(s.snum) as 'bjg_rs'
from student s,course c,sc,sections sec
where s.snum = sc.snum and
sc.secnum = sec.secnum and
sec.cnum = c.cnum and
sc.score < '60'
group by sec.cnum,c.cname) b

on a.cnum = b.cnum

㈣ SQL統計每門課程的不及格人數

你的要求有點特別,要求 學號!
如果只是
統計每門課程的不及格人數下面的SQL就可以啦:
select cnum,count(cnum) as 不及格人數
from sc
where score < 60
group by cnum 注意:是對課程號分組喲,樓上的是錯的。

如果你要輸出學號:
Select sc.snum as 學號,
a.cnum as 課程號,
a.不及格人數
From sc,
(select cnum,count(cnum) as 不及格人數
from sc
where score < 60
group by cnum) as a
where sc.score<60 and sc.cnum=a.cnum

以上我相信是沒有問題的,你測試一下!
如果OK,給分喲
呵呵

㈤ SQL,將各門課程缺少考試成績的學生查詢出來

SELECTDISTINCT學生表.學生ID,姓名FROM學生表,成績表
WHERE學生表.學生ID=成績表.學生ID
AND成績ISNULL;

㈥ oracle sql查詢缺考的學生

select 學號, sum(課程一成績, 課程二成績, 課程三成績) as 總成績 from 表 where 總成績 is null;
這樣寫試一下。

㈦ SQL語句求助,查詢出每門課程及格和不及格的人數

---以下在SQL2005執行通過--
---結果將以 科目、及格數、不及格數 顯示
select * from
(select col2,count(*) as [及格數]
from tb
where col1>=60
group by col2
)t
outer apply
(select count(*) as [不及格數]
from tb
where col1<60 and t.col2= col2
group by col2
)m

-----這應該是樓主想要的了吧。

㈧ SQL語句求助,查詢出每門課程及格和不及格的人數

select a.score ,count as 人數 ,col2 as 科目 from
(select case when col1>=60 then '及格' else '不及格' end as score ,col2 from tb g )
a group by a.score,a.col2

㈨ SQL語句求助:統計各班每門課程成績均不及格的同學人數

根據題目要求,簡單分析可以知道,其實這條查詢語句只使用「學生選課」和「學生」這兩張表即可。此處應該使用「左連接」,用學生表中的班級欄位進行「分組」,用COUNT()函數對分數小於60的同學的個數進行統計。

SELECT 學生.班級,COUNT(學生選課.成績<60)
FROM 學生選課
LEFT JOIN 學生
ON 學生選課.學生ID=學生.學生ID
GROUP BY 學生.班級

你可以進行驗證一下,如果不對,或者有更優化的方法,可以相互學習!

㈩ SQL 查詢某門課程及格的總人數以及不及格的總人數以及沒成績的人數

1、創建測試表,

create table test_score(class_id varchar2(20), student_id varchar2(20), score number);