A. 如何用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語句的時候,要在英文環境下輸入。否則可能會出現代碼不識別。
B. 求sql語句 60分以下顯示為不及格
用case語句
select
姓名,
case
分數
when
分數<60
then
"不及格"
else
分數
end
from
table
C. sql 查詢小於60分的人 並且提高5分
sql 查詢小於60分的人 並且提高5分,根本不需要遍歷,直接一個語句修改即可
update ScoreDetails set Score=Score+5 where Score<60
D. sql中將成績小於60的同學姓名添加內容,例如張三(不及格)
select concat(姓名欄位,"(不及格)") from 表名 where 成績欄位 < 60
E. 用T-SQL語句刪除AQL成績表中所有成績不及格(分數小於60) 的學生
delete from student st
where st.student_no in(select a.student_no from AQL a where a.mark < 60 and st.student_no = a.student_no);
F. sql求學生總學分(分數低於60則算零分)
// 從學生成績表user_score匯總成績score
// 取成績時加一層判斷,分數小於60算0分否則算實際分數
select sum(case when score<60 then 0 else score end) from user_score
G. sql2000 大於60分不變,小於60替換成不及格
SELECT
NAME,SCORE=
CASE
WHEN
SCORE<60
THEN
'不及格'
else
SCORE
END
FROM
CHANGE
或者:
SELECT
NAME,SCORE=
CASE
WHEN
SCORE<60
THEN
'不及格'
when
SCORE>=60
then
SCORE
END
FROM
CHANGE