case when then的问题?
sum(case parentId when 0 then 1 else 0 end)
sum(case when parentId=0 then 0 else 1 end)
这两句是啥意思?有什么不同?
[解决办法]
sum(case parentId when 0 then 1 else 0 end)
统计 parentId=0 的记录条数
sum(case when parentId=0 then 0 else 1 end)
统计 parentId <> 0 的记录条数
[解决办法]
lixk2000() ( ) 信誉:100 Blog 加为好友 2007-06-07 08:43:43 得分: 0
每一个是:
计算parentId=0的记录条数
每二个是:
计算parentId <> 0的记录条数
为什么是这个结果?
-----------
上面不是有解?
sum(case parentId when 0 then 1 else 0 end)
逐比表中每,如果parentId=0的话,就加上1 如果parentId <> 0 ,就加上0,最後的到的果就是“计算parentId=0的记录条数”。