select
User.ID as UserID,
case count(distinct
case
when Amount>0 or Fee>0 then userid
else null
end
)
when 0 then 0
else 1
end ,
case count( distinct
case IsEnabled
when 1 then userid
else null
end)
when 0 then 0
else 1
end ,
accontID from a.......这里
case count(distinct
case
when Amount>0 or Fee>0 then userid
else null
end
)
when 0 then 0
else 1
end ,
case count( distinct
case IsEnabled
when 1 then userid
else null
end)
when 0 then 0
else 1
end 是什么意思 ??
User.ID as UserID,
case count(distinct
case
when Amount>0 or Fee>0 then userid
else null
end
)
when 0 then 0
else 1
end ,
case count( distinct
case IsEnabled
when 1 then userid
else null
end)
when 0 then 0
else 1
end ,
accontID from a.......这里
case count(distinct
case
when Amount>0 or Fee>0 then userid
else null
end
)
when 0 then 0
else 1
end ,
case count( distinct
case IsEnabled
when 1 then userid
else null
end)
when 0 then 0
else 1
end 是什么意思 ??
V1=0 ? 0 : 1V2: IsEnabled=1 的不重复 userid 数
V2=0 ? 0 : 1
sign(count(case IsEnabled when 1 then userid end))
case count(distinct case when Amount>0 or Fee>0 then userid else null end )
when 0 then 0
else 1
end ,这样明白了点 应该是这个意思 case when Amount>0 or Fee>0 那个count(distinct userId)的数据 ,否则 count(distinct null)
如果count(distinct结果为0--》 0
count(distinct结果不为0 ---》 1
如果为0,没有此条件userid,则为0,如果有,则为12,采用case嵌套
统计满足IsEnabled=1条件不重复userid的个数
如果为0,没有此条件userid,则为0,如果有,则为1
;
+----------------------+
| count(distinct null) |
+----------------------+
| 0 |
+----------------------+
1 row in set-------------可行的