sum(case parentId when 0 then 1 else 0 end)
sum(case when parentId=0 then 0 else 1 end)
这两句是啥意思?有什么不同?
sum(case when parentId=0 then 0 else 1 end)
这两句是啥意思?有什么不同?
解决方案 »
- 求两个日期间隔时间的最佳表达方式!
- sql server 2005 连接服务器,仅仅看到部分表
- 这样一个从txt导入mssql的语句应该怎么写
- 表复制问题
- sql server服务器电脑升级防火墙后,发现客户端无法连接服务器了,什么原因?
- 在读取某条@Id记录的时候,将其int类型的字段hits自动加1
- 我XPSP3GHOST系统,无法安装SQL2005的组件,只最后一个可以安装,剩下的都是灰色,不能选择,求解决办法
- 求助数据库设计!
- 跪求高手指教,这样用一条SQL怎么实现。。。。。在线等
- sql server有什么好书介绍
- 怎么取表的备注信息?
- 请教一条查询和插入的Sql语句(可能有点复杂,达人帮忙)
等同於
sum(case when parentId=0 then 1 else 0 end)when放在前後沒關係的。
统计 parentId=0 的记录条数sum(case when parentId=0 then 0 else 1 end)
统计 parentId<>0 的记录条数
sum(case when parentId=0 then 0 else 1 end)
---------------------------------------这两句结果不同,但语法都正确then else后面的1和0是什么意思?
-----------------------
是说如果parentId=0的话,就等于1 如果parentId<>0 ,就等于0
是什么等于1?等于0?是ParentId吗?
是说如果parentId=0的话,就等于1 如果parentId<>0 ,就等于0
是什么等于1?等于0?是ParentId吗?
-----------錯了,實際應該上
如果parentId=0的话,就加上1 如果parentId<>0 ,就加上0
其實 Yang_(扬帆破浪) ( ) 信誉:132 Blog 加为好友 2007-6-2 16:54:01 得分: 0
sum(case parentId when 0 then 1 else 0 end)
统计 parentId=0 的记录条数sum(case when parentId=0 then 0 else 1 end)
统计 parentId<>0 的记录条数
已經說的很明白了
sum(case parentId when 0 then 1 else 0 end)
它是統計parentId<>0的紀錄條數
但是具體計算是這樣的 返回結果=(先統計出parentId<>0的紀錄條數 * else後面的哪個值)+then後面的那個值sum(case when parentId=0 then 0 else 1 end)
它是統計parentId<>0的紀錄條數
但是具體計算是這樣的 返回結果=(先統計出parentId<>0的紀錄條數 * else後面的哪個值)+then後面的那個值
sum(case parentId when 0 then 1 else 0 end)
它是統計parentId=0的紀錄條數而它的就是就只是
返回結果=統計出parentId=0的紀錄條數
计算parentId=0的记录条数
每二个是:
计算parentId<>0的记录条数
计算parentId=0的记录条数
每二个是:
计算parentId<>0的记录条数
----------------
就是呀
计算parentId=0的记录条数
每二个是:
计算parentId<>0的记录条数为什么是这个结果?
每一个是:
计算parentId=0的记录条数
每二个是:
计算parentId<>0的记录条数为什么是这个结果?
-----------
上面不是有解釋嗎?
sum(case parentId when 0 then 1 else 0 end)逐條對比表中每條紀錄,如果parentId=0的话,就加上1 如果parentId<>0 ,就加上0,最後的到的統計結果就是“计算parentId=0的记录条数”。
计算parentId=0的记录条数
每二个是:
计算parentId<>0的记录条数
统计 parentId=0 的记录条数sum(case when parentId=0 then 0 else 1 end)
统计 parentId<>0 的记录条数正解 学习
统计 parentId=0 的记录条数sum(case when parentId=0 then 0 else 1 end)
统计 parentId<>0 的记录条数