当前位置:网站首页>SQL learning - case when then else

SQL learning - case when then else

2022-07-05 09:27:00 Xu Jiajia 233

scene

There is currently one “ Student transcript ”
It is necessary to inquire which students have passed , Which failed .

Example

create table StudentScore (
	name string,
	score int
);

INSERT INTO StudentScore VALUES
('AAA',32),
('BBB',58),
('CCC',62),
('DDD',92);

select Inquire about

select name,
case 
when score >= 90 then ' good '
when score >= 60 then ' pass '
else ' fail, '
end as test_result
FROM StudentScore;

result

 Insert picture description here

原网站

版权声明
本文为[Xu Jiajia 233]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140538084848.html