單錶查詢及格和不及格人數,SQL 查詢某門課程及格的總人數以及不及格的總人數以及沒成績的人數

時間 2022-07-23 01:35:24

1樓:刀頤然

學過資料庫沒有啊,可以先把那些成績新增進資料庫裡面,然後再進行查詢。

定義乙個變數

再加上if判斷

如果符合幾個的就給這個變數加上一

如果沒學過的話

還可以用陣列來做

2樓:匿名使用者

select banji as '班級',sum(decode(fenshu>=60,1,0)) as '及格數',sum(decode(fenshu<60,1,0)) as '不及格數

' from tablea group by banji

3樓:匿名使用者

可以用access很好處理**。

4樓:匿名使用者

這個不太可能的,一般都是取出資料再通過其他的來計算,一條語句。。。我也很期待。。。

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

5樓:匿名使用者

1、建立測試表,

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

2、插入測試資料

insert into test_score values ('c07', 1001, 50);

insert into test_score values ('c07', 1002, 72);

insert into test_score values ('c07', 1003, 85);

insert into test_score values ('c07', 1004, 91);

insert into test_score values ('c07', 1005, 48);

insert into test_score values ('c07', 1006, 79);

insert into test_score values ('c07', 1007, null);

3、查詢表的記錄,select t.*, rowid from test_score t;

4、編寫sql,查詢某某課程及格的總人數以及不及格的總人數以及沒成績的人數,

select class_id,

count(distinct case when score < 60 then student_id end) s1,

count(distinct case when score >= 60 then student_id end) s2,

count(distinct case when score is null then student_id end) s3

from test_score t group by class_id,

6樓:環柏

select sum(case when 成績》=60 then 1 else 0 end) as 及格人數,sum(case when 成績<60 then 1 else 0 end )as 不及格人數,sum(case when 成績 is null then 1 else 0 end )as 沒有成績人數 from 成績表

7樓:du瓶邪

兩種方法

select case when score>60 then '及格' else '不及格' end as '類別',count (*) as '人數' from db_score

group by case when score>60 then '及格' else '不及格' end

-------------------------------------

select '不及格' as '類別' ,count(*)as '人數' from db_score where score<60

union all

select '及格' as '類別' ,count(*) as '人數' from db_score where score>=60

分別統計及格及不及格的總人數用sql語句

8樓:匿名使用者

這裡提供乙個各種資料庫都通用的寫法供參考

假設資料表結構為:

分數表(姓名,分數)

select count(t.p) as 格及總人數,count(t.f) as 不格及總人數

from (

select 1 as p,0 as f  from 分數表 where 分數》=60

union all

select 0,1  from 分數表 where 分數<60) t;

excel**問題,如何統計不及格人數

9樓:匿名使用者

在每個學生後面e列做公式 =if(b2<60,"不及格",if(c2<60,"不及格",d2<60,"不及格","")))。以三項成績為例,姓名在a2,成績在b2、c2、d2最多可以有7個成績。然後將公式下拉至每個學生。

假設20名學生,在e22做公式 =countif(e2:e21,"不及格")。就統計不及格人數。

10樓:匿名使用者

樓主,方法不必多,只需解決問題,簡單就好.

假設, a2:a100為某科成績, 不及格公式如下:

1. =countif(a2:a100,"<60")2. =sumproduct(--(a2:a100<60))不及格人數就是單科不及格人次相加.

11樓:鬱渟

假設學生成績在b2:d100,3門課的及格分數線分別為60 72 60

陣列公式(輸入後按ctrl+shift+enter完成)=sum(--(mmult(--(b2:d100<),row(1:3)^0)>0))

ps:如果有n門課程修改分數線,同時修改3為n即可。

12樓:芮城老憨

假如學科有五門,在後面一空單元格如h2裡輸入陣列公式:

〔=sum(if(b2:f2<60,1)]得到該學生有幾門不及格,接著就好辦了,在最後輸入乙個統計函式〔=countif(h2:h100,">=1")]

結果就是有一門以上不及格的學生數字.

13樓:

可以先用if及and函式,把不及格的學生篩選出來,接下來就直接用count函式實現統計。

excel怎樣對學生及格人數和及格率統計

14樓:晴空的晨曦

具體解決步驟如下:

1.選擇任意單元格輸入結果,新增公式

2.在單元格內打出=countif,出現公式,點選。

3.括號內分為兩部分,第一部分選擇統計及格數的列4.第二部分選擇幾個標準,注意打出冒號和另外半個括號。

15樓:匿名使用者

函式countif和count

假定單元格b2到b46是某科成績。及格(優生)人數:=countif(b2:b46,">=x")。

及格率或優生率:=countif(b2:a46,">=x")/count(b2:b46)。

其中x表示及格分數或優生分數,count(b2:b46)用於統計參考人數。 單元格區域b2:b46可用滑鼠拖動選擇。

16樓:匿名使用者

二樓的,如果你給他做好了,那他下次還不是不會做,那有什麼用,別人要的是做的方法,下次再遇到就能自己做好

用函式count 語文》=60

17樓:奧運小火

這樣的問題 資料透視表 應該簡單點吧

對 是相當簡單

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

18樓:庹熙系惜萍

select

學號,課程號,count(*)

as不及格人數

from

scwhere

分數<60

group

by學號,課程號

union

select

'不及格人數','->',sum(count(*))as不及格人數

from

scwhere

分數<60

group

by學號,課程號

order

by不及格人數

19樓:匿名使用者

你的要求有點特別,要求 學號!

如果只是

統計每門課程的不及格人數下面的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,給分喲呵呵

20樓:匿名使用者

統計每門課程不及格人數,那就根據課程號做分組統計即可,但是輸出時肯定不能輸出學號!學號是針對每個學生的。

select cnum,count(1) from sc where score<60 group by cnum

21樓:匿名使用者

snum,cnum,score < 60 (不及格分數如果是60的話)

22樓:

select snum,cnum

from sc

where score<60

order by score,snum

compute count(snum)

用compute,就可以同時返回學號,課程號,和分數啦……

23樓:閉鯨白俊賢

select

a.score

,count

as人數

,col2

as科目

from

(select

case

when

col1>=60

then

'及格'

else

'不及格'

endas

score

,col2

fromtbg

)agroup

bya.score,a.col2

24樓:匿名使用者

select cnum,count(snum)from sc

where score < 60

group snum

怎麼用一條sql語句查出學生表成績小於60為不及格60-80為良好80-90為優秀? 15

25樓:飛fly飛

select name,case when 成績<60 then 不及格 when 成績》=60 and 成績<80 then 良好 when 成績》=0 and 成績<90 then 優秀 end as 成績情況 ,from 表名。

注意,在輸入sql語句的時候,要在英文環境下輸入。否則可能會出現**不識別。

拓展內容:

結構化查詢語言(structured query language)簡稱sql,結構化查詢語言是一種資料庫查詢和程式語言,用於訪問資料以及查詢、更新和管理關係資料庫系統。sql 語句就是對資料庫進行操作的一種語言。

一些sql 語句示例如下:

資料庫:create database database-name

刪除資料:drop database dbname

建立表:create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)

刪除新錶:drop table tabname

增加:alter table tabname add column col type

設主鍵:alter table tabname add primary key(col)

刪除主鍵:alter table tabname drop primary key(col)

建立索引:create [unique] index idxname on tabname(col….)

刪除索引:drop index idxname

建立檢視:create view viewname as select statement

刪除檢視:drop view viewname

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

1 建立測試表,create table test score class id varchar2 20 student id varchar2 20 score number 2 插入測試資料 insert into test score values c07 1001,50 insert int...

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

管朵景密 用一條語句不好查,本身就是兩個條件,又返回的兩個結果,怎麼用一條語句? select col2,count col1 as 及格學生人數,count count col1 as 不及格學生人數 from td where col1 60 鱈舞 好難回答你問的問題,因為你的表就沒有建好,如何...

Excel中求列中不及格的人數怎麼做

晁荌 在上方工具條中點選 篩選 輸入判定不及格的分數,點確認,結果就出來了! excel辦公實戰 使用countif函式處理 excel版本參考 2010 假設測試資料在 a列和b列 1 c輸入公式 countif b b,60 2 回車,檢視結果 看輕自己 用count if函式 假如在f列 co...