[英]I want to count a count inside of a case statement
I'm using this code to try to get the number of parcels that have multiple imps inside a neigh.我正在使用此代码来尝试获取在 neigh 内具有多个小鬼的包裹数量。
SELECT r.neighbhood
,count(CASE
WHEN count(p.repropkey > 1)
THEN 1
ELSE NULL
END) AS 'Multiple Imps'
FROM realprop r
LEFT JOIN reprop p ON r.realkey = p.realkey
WHERE r.fmvres > 0
GROUP BY r.neighbhood
I don't know why you are nesting count()
s.我不知道你为什么要嵌套
count()
s。 Does this do what you want?这是你想要的吗?
SELECT r.neighbhood,
(CASE WHEN count(p.repropkey > 1) THEN 1
END) AS Multiple_Imps
FROM realprop r LEFT JOIN
reprop p
ON r.realkey = p.realkey
WHERE r.fmvres > 0
GROUP BY r.neighbhood
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.