Labels

Wednesday, 23 December 2015

SQL Server - Having Clause


Having

 After group by clause we are not allowed to use where clause , in place of this one SQL provided having clause .

Syntax : Having <Search Condition >

Note 
                Generally if you want to restrict rows then we are using where clause where as if you want to restrict groups we are using having clause.


Write a query to display deptno's having more than 5 employees?

select deptno,count(*) from emp group by deptno having count(*)>5


2 comments: