获取专栏' threshold.threshold'在having子句中无效,因为它不包含在聚合函数或group by子句中

时间:2015-02-10 08:36:33

标签: c# sql-server-2008

获取专栏' threshold.threshold'在having子句中无效,因为它不包含在聚合函数或group by子句中 这是我的代码..

SELECT ITEM.ITEMS, SUM(ITEM.REORGANIZED) AS TOTAL FROM THRESHOLD CROSS JOIN ITEM GROUP BY ITEM.ITEMS HAVING (SUM(ITEM.REORGANIZED) > THRESHOLD.THRESHOLD)

这里,我有threshold.threshold错误...阈值是一个整数值..如果我使用600而不是threshold.threshold意味着它将工作...

如何清除错误???

2 个答案:

答案 0 :(得分:0)

(SUM(ITEM.REORGANIZED)>(从阈值中选择阈值)

它正在运作

答案 1 :(得分:0)

尝试使用MIN或MAX函数聚合THRESHOLD.THRESHOLD字段,如下所示:

SELECT ITEM.ITEMS, SUM(ITEM.REORGANIZED) AS TOTAL
FROM THRESHOLD CROSS JOIN ITEM
GROUP BY ITEM.ITEMS
HAVING (SUM(ITEM.REORGANIZED) > MAX(THRESHOLD.THRESHOLD))

我希望这会有所帮助!!