T-SQL HAVING
HAVING子句,是对合计函数进行条件过滤。就以这个http://www.cnblogs.com/insus/articles/1968148.html准备的数据为例。
查询出这些天来,每天记录和大于等于140次的日期。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
SELECT [DT] ,SUM([Hits]) AS [TotalHits] FROM [dbo].[RecordHits]
GROUP BY [dt]
HAVING SUM([Hits]) >= 140
GROUP BY [dt]
HAVING SUM([Hits]) >= 140
执行结果: