我的下面的查询有什么问题。我收到此错误"错误的参数数量。
期待3个论点"我认为我在SUM声明中出错了
SELECT
groupname,
EXACT_COUNT_DISTINCT(prodname) AS COUNT_prodname,
SUM(IF(category = 'AAA') AND (Label = 'n')) AS COUNT_prod_success
FROM
[mytable]
WHERE
name CONTAINS('XYZ')
AND Package ='ABCD'
AND (StartTime > ('2016-01-24 00:00:00 UTC')
AND StartTime < ('2016-03-16 00:00:00 UTC')
OR (StartTime > ('2016-03-26 00:00:00 UTC')
AND StartTime < CURRENT_TIMESTAMP()))
GROUP BY
1
ORDER BY
2 DESC IGNORE CASE
答案 0 :(得分:2)
这里有IF()函数的问题
IF(category =&#39; AAA&#39;)
IF函数需要三个参数 -
<h2>1715</h2>
<div class="img-wrapper">
<img src="http://cdn.xl.thumbs.canstockphoto.com/canstock24510515.jpg" >
</div>
所以它应该像
IF(condition, true_return, false_return)
此外 - 这里看起来很可疑(但肯定可以通过设计)低于(IF以外的额外条件)
IF(category = 'AAA', 1, 0)
很有可能你的意思是
AND (Label = 'n')