如何将sum(ye)为空转化为0呢?
如何将sum(ye)为空转化为0呢?db2 "select sum(ye) from test where zh='12345678'"
上面的结果,如果zh不存在,则sum(ye) 返回一个空间,如何让sum(ye)返回0呢?也就是如何转化。
回复 #1 rich_ying 的帖子
Select Sum(case IsOnline = 1 then 1 else 0) as OnlineProducts, Sum(case IsOnline = 0 then 1 else 0) as OfflineProducts, Sum(case IsHot = 1 then 1 else 0) as ...www.bofux.com/?p=221
类似这样的可以吗? COALESCE函数不是很好用吗。 楼上说的对!
db2 "select sum(COALESCE(ye,0)) from test where zh='12345678'"
这样去试试! db2 "select value(sum(ye),0) from test where zh='12345678'"
页:
[1]