Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
Having clause in sql server examples in Queries of SQL Queries
2154 Views
Hints 
Having keyword only used when group by keyword present.If you use group by cant use aggregate function with where keyword to check conditions,Instead of that having keyword is used.

In following example, Group by and having keywords are used.
Syntax
select columnName from tableName group by columnName having COUNT(columnName)>value;

//When use group by according to the condtion having clause used.
Example
Get the jobs that are done by more than two employees.

select job from Works_on group by job having COUNT(emp_no)>2;
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details