❶ 求sql語句 60分以下顯示為不及格
用case語句
select
姓名,
case
分數
when
分數<60
then
"不及格"
else
分數
end
from
table
❷ 如何用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 分組計算合格率問題
select 廠家,型號,不合格數量,合格數量,合格數量/((不合格數量+合格數量)/1.00) 合格率, 不合格數量/((不合格數量+合格數量)/1.00) 不良率 from (
select 廠家,型號,sum((case when 狀態=7 then 數量 else 0 end))不合格數量,sum((case when 狀態<>7 then 數量 else 0 end)) 合格數量 from (
select 廠家,型號,狀態,SUM(數量)數量 from tab
group by 廠家,型號,狀態,SUM(數量)
) t
group by 廠家,型號
) t2