码迷,mamicode.com
首页 > 移动开发 > 详细

SQL Query aggregate may not appear in WHERE clause

时间:2021-01-28 12:25:03      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:break   color   rgba   period   get   pre   tps   link   ota   

SQL Query aggregate may not appear in WHERE clause

 

错误的写法

SELECT StartDate,
       ClientID,
       COUNT(1) AS Total
FROM dbo.tbm_cti_CustomTableItem_BudgetPeriod
WHERE COUNT(1) <> 1
GROUP BY StartDate,
         ClientID;

 

 

正确的写法

SELECT StartDate,
       ClientID,
       COUNT(1) AS Total
FROM dbo.tbm_cti_CustomTableItem_BudgetPeriod
GROUP BY StartDate,
         ClientID
HAVING COUNT(1) <> 1;

 

SQL Query aggregate may not appear in WHERE clause

标签:break   color   rgba   period   get   pre   tps   link   ota   

原文地址:https://www.cnblogs.com/chucklu/p/14338327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!