sql遇到的业务逻辑,先mark,有空再用用例测试一下。
需要筛选同环比绝对值大于50%的数据;
前情提要:
前人写的代码:
where case when avgq is not null and avgq <> 0
then abs(hbl) > 0.5
case when (avgq is null or avgq = 0)
and avgtb is not null
and avgtb <> 0
then abs(tbl) > 0.5
end
我的想法:
where (avgq is not null and avgq <> 0 and abs(hbl) > 0.5)
or (avgtb is not null and avgtb <> 0 and abs(tbl) > 0.5)
不知道两种写法有什么不同,恕我愚笨,不知道什么天才会有where case when 的想法,如有靓仔靓女闲着没事,欢迎讨论。
你好像逻辑没解释的通。