--建表
create table mytable(a int,b int,c int, d int)
--查表(通过case when)
select * from mytable
select a,b,c,d
,case when b=0 then
0
else
(t.a-t.b)/t.b
end case
from mytable t
本文介绍如何使用SQL查询结合CASE WHEN表达式进行条件判断,实现数据的灵活处理。
--建表
create table mytable(a int,b int,c int, d int)
--查表(通过case when)
select * from mytable
select a,b,c,d
,case when b=0 then
0
else
(t.a-t.b)/t.b
end case
from mytable t
3135

被折叠的 条评论
为什么被折叠?