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

sql分數等級

發布時間: 2022-04-29 18:01:58

sql高手進來 通過積分查找等級

***************************
補充:
說過了,在你的積分表中增加一列等級積分上限,這個表就有用了。這樣當修改你的積分表的時候,級別顯示就會跟著變,就不存在寫死的問題了。
***************************

你的資料庫是這樣,沒有辦法,只能用case語句一個一個找,如果你嫌麻煩,建議在【積分表】中加一個【等級積分上限】欄位。
如:【2,士兵,200,499】代表積分在【200到499】之間的是【士兵】,這樣sql寫起來就簡單多了。

select A.用戶號,A.用戶名,A.積分,B.等級名稱 from 用戶表 A,積分表 B where A.積分<=B.積分上限 and A.積分>=B.積分;

這樣一下就定位了,B表只有一個欄位確實不好定義。

---
以上,希望對你有所幫助。

⑵ 怎樣使用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 ksh,sd,case when fs<60 then 'C' case when fenshu between 60 and 80 then 'B' else then 'A' end from stu

⑸ SQL資料庫:按成績【90,100】評『A』;【80,89】評『B』 【70,79】評『C』 【0,69】評『D』

with etc as
(
SELECT A.S# as s#,B.CNAME as cname,A.GRADE as grade FROM SC AS A JOIN C AS B
ON A.C#=B.C#)
select a.sname as 姓名,b.cname as 課程名,
(case when grade >=90 and grade <=100 then 'A'
when grade >=80 and grade <=89 then 'B'
when grade>=70 and grade<=79 then 'C'
else 'D' end) as 成績
from s as a join etc as b
on a.s#=b.s#
order by b.grade desc

⑹ 如何用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語句的時候,要在英文環境下輸入。否則可能會出現代碼不識別。

⑺ Ms Sql 2000如何實現給分數評等級

select id,rank=when(
case Score<60 then 不及格
case Score>60 and Score<70 then 及格
case Score>70 and Score<80 then 中
case Score>80 and Score<90 then 良
case Score=100 then 優
)
form table2
group by ID

這是SQL Server 2000下的查詢語句,不知道適合不

⑻ 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如何根據分數進行分組

select成績,
casewhen成績>=90then'A'when成績>=80then'B'when成績>=70then'C'else'D'endas`group`
from表;

Case具有兩種格式。簡單Case函數和Case搜索函數。

--簡單Case函數

CASEsexWHEN'1'THEN'男'WHEN'2'THEN'女'ELSE'其他'END

--Case搜索函數

CASEWHENsex='1'THEN'男'WHENsex='2'THEN'女'ELSE'其他'END

該例中即可採用case搜索函數