當前位置:首頁 » 編程語言 » sql查詢數學零分的人數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql查詢數學零分的人數

發布時間: 2023-01-12 04:50:32

㈠ 有學生表(編號,姓名,班級),成績表(學生編號,科目編號,成績) sql查詢學生編號,姓名,科目成績,沒成績的為0

1
select 學生表.編號,
姓名,
isnull(s1.語文成績,0) as 語文成績,
isnull(s2.數學成績,0) as 數學成績,
isnull(s3.英語成績,0) as 英語成績
FROM 學生表 left join
(select 學生編號, 科目, 成績 as 語文成績 from 成績表 where 科目編號 = '語文') s1 on 學生表.編號 = s1.學生編號 left join
(select 學生編號, 科目, 成績 as 數學成績 from 成績表 where 科目編號 = '數學') s2 on 學生表.編號 = s2.學生編號 left join
(select 學生編號, 科目, 成績 as 英語成績 from 成績表 where 科目編號 = '英語') s3 on 學生表.編號 = s3.學生編號

2.
select 班級, 科目編號, avg(成績) as 平均成績 from 學生表, 成績表 where 學生表.編號 = 成績表.學生編號 group by 班級, 科目編號

㈡ 用sql語句查找各班的及格人數

樓主要的應該是以上結果,把條件放在 case when ..

select 班級,sum(case when 考試分數>=60 then 1 else 0 end) as 及格
from 學生
group by 班級

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

1、創建測試表,

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

㈣ sql怎麼統計某一課程的各分數段的人數(在php程序里)

實現上面sql查詢結果的記錄總數
$sql = select count(C.`cid`) as `c` from (select * from `ctable` group by pid) as C left join `ptable` as P on P.`pid` = C.`pid`;
詳解,此語句用到了sql子查詢,先使用子查詢對ctable進行分組查詢,然後對分組後的結果集進行統計.

㈤ 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命令實現查詢,查詢平均分不及格的學生人數。怎麼寫啊

已知:
選課表(學號,課程編號,成績)

查詢平均分不及格的學生人數的SQL代碼:
select 平均分不及格的學生人數 = count(*)
from 選課表
where 學號 in ( select 學號,avg(成績)
from 選課表
group by 學號
having avg(成績) < 60 )

㈦ 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查詢 統計每門課的選課人數及不及格人數

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 count(case 分數欄位 when 100 then 1 end) as [滿分],
count(case when 分數欄位 between 90 and 99 then 1 end) as[90-99分],
count(case when 分數欄位 between 80 and 89 then 1 end) as[80-89分],
count(case when 分數欄位 between 70 and 79 then 1 end) as[70-79分],
count(case when 分數欄位<70 then 1 end) as[70分以下]
from 學生分數表

㈩ 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,給分喲
呵呵