當前位置:首頁 » 編程語言 » sql語句查詢學生成績等級劃分
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql語句查詢學生成績等級劃分

發布時間: 2022-12-30 21:21:56

sql通過分數查詢所在等級 急急急!!!

select 員工編號,考核分數,等級=case
when 考核分數<=100 and 考核分數>=90 then '優等'
when 考核分數<=89 and 考核分數>=80 then '甲等'
when 考核分數<=79 and 考核分數>=70 then '乙等'
when 考核分數<=69 and 考核分數>=60 then '丙等'
else '丁等' end
from employee_Test

⑵ 如何用sql語句查出學生表成績小於60為不及格60-80為良好80-90為優秀

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

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

⑶ 查詢每個學生的各科成績sql語句

1、查詢每個學生的各科成績sql語句:

select a.studentid,a.name,a.sex,v1.score as '語文',v2.score as '數學', v3.score as '英語',v4.score

as 『哲學』, (v1.score+v2.score+v3.score+v4.score)/4 as 『平均成績』 from Stuednt a
left join

(select studentid,score from grade where cid=(select cid from course where cname='語文'))as v1

on a.studentid=v1.studentid

left join

(select studentid,score from grade where cid=(select cid from course where cname='數學'))as v2

on a.studentid=v2.studentid

left join

(select studentid,score from grade where cid=(select cid from course where cname='英語'))as v3

on a.studentid=v3.studentid

left join

(select studentid,score from grade where cid=(select cid from course where cname='哲學'))as v4

on a.studentid=v4.studentid

order by a.studentid

2、sql資料庫介紹:

(1)SQL是Structured Query Language(結構化查詢語言)的縮寫。SQL是專為資料庫而建立的操作命令集,是一種功能齊全的資料庫語言。在使用它時,只需要發出"做什麼"的命令,"怎麼做"是不用使用者考慮的。

(2)SQL功能強大、簡單易學、使用方便,已經成為了資料庫操作的基礎,並且現在幾乎所有的資料庫均支持SQL。

(3)SQL資料庫的數據體系結構基本上是三級結構,但使用術語與傳統關系模型術語不同。

(4)在SQL中,關系模式(模式)稱為"基本表"(base table);存儲模式(內模式)稱為"存儲文件"(stored file);子模式(外模式)稱為"視圖"(view);元組稱為"行"(row);屬性稱為"列"(column)。

⑷ 怎樣使用sql語句可以多條件查詢 比如成績等級劃分

select sum(case when '成績'=100.0 then 1 else 0 end),
sum(case when '成績'<100 and '成績' >=90 then 1 else 0 end),
sum(case when '成績'<90 and '成績' >=80 then 1 else 0 end),
sum(case when '成績'<80.0 and '成績' >=70 then 1 else 0 end),
sum(case when '成績'<70.0 and '成績' >=60 then 1 else 0 end),
sum(case when '成績'<60 then 1 else 0 end) from table
可以按分數間隔統計出成績分布,分別是100分有多少人,90~100,80~90,70~80,60~70,60以下的區間分別有多少人。

⑸ 創建SQL查詢,用SELECT語句為"成績"表各科成績做一個A,B,C的等級評分

就是一個case when語句,這個沒什麼困難的
select (case when 成績>=90 then 'A' when 成績>=80 and 成績<90 then 'B' esle 'C' end) 評級 from table
具體的內容自己改,我用的是oracle的寫法,其他資料庫也有case when語句用法差不多,如果不是oracle資料庫,那麼要自己改一改才能用。

⑹ SQL語句查詢每個學生的學號、姓名、平均成績、最高成績和最低成績

select 學生表.學號,學生表.姓名,
average(成績表.成績) as 平均成績,
max(成績表.成績) as 最高成績,
min(成績表.成績) as 最低成績
from 學生表 left join 成績表 on 學生表.學號=成績表.學號
order by 學生表.學號
成績表可換成語文、數學、英語等,查詢結果就是各個學生相應課程的平均成績、歷史最高成績、歷史最低成績.

⑺ sql查詢語句的分級問題

select 姓名,成績,case when 成績>=60 then '及格' else '不及格' end 等級
from student

如果成績是varchar型的,60要用'60'替代

⑻ 按照人名查出學生的各科成績以及總成績並按總成績排名的sql語句

按照人名查出學生的各科成績以及總成績並按總成績排名的sql語句示例如下:

selectA.name,

(selectB.scorefromtable_scoreBwhereB.type='數學'andA.id=B.id)as數學,

(selectB.scorefromtable_scoreBwhereB.type='語文'andA.id=B.id)as語文,

(selectB.scorefromtable_scoreBwhereB.type='英語'andA.id=B.id)as英語,

(selectSUM(B.score)fromtable_scoreBwhereA.id=B.id)assum_score

fromtable_studentAorderbysum_scoreDESC

以上sql語句首先把學生表和成績表聯合查出每個學生的數學、語文、英語成績,然後通過selectSUM(B.score)fromtable_scoreBwhereA.id=B.id查出每個學生的總成績。

最後orderbysum_scoreDESC實現按總成績倒敘排列。


(8)sql語句查詢學生成績等級劃分擴展閱讀

上述sql語句重點是對as關鍵字的使用-Alias(別名),通過使用SQL,可以為列名稱和表名稱指定別名(Alias)。

表的SQLAlias語法

SELECTcolumn_name(s)FROMtable_nameASalias_name;

列的SQLAlias語法

SELECTcolumn_nameASalias_nameFROMtable_name;

Alias實例:使用表名稱別名

假設我們有兩個表分別是:"Persons"和"Proct_Orders"。我們分別為它們指定別名"p"和"po"。

現在,我們希望列出"JohnAdams"的所有定單。

我們可以使用下面的SELECT語句:

SELECTpo.OrderID,p.LastName,p.FirstNameFROMPersonsASp,Proct_OrdersASpoWHEREp.LastName='Adams'ANDp.FirstName='John'