Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what’s the difference between the having clause and the where clause?
Posted
Comments
ZurdoDev 23-Mar-12 7:53am    
Is this a homework question? Having is used with grouping. What exactly do you need though?
viveksri06 23-Mar-12 8:08am    
This question has been asked in interview...

XML
Because we can not use Where clause with <b>aggregate functions </b>like <b>count(),min(), sum()</b> etc. so <b>having clause</b> came into existence to overcome this problem in sql. see example for having clause go through this link

http://www.sqlfundamental.com/having-clause.php
 
Share this answer
 
Having works with Group by and aggregate function. And where you can use in direct column.

For Example:

SQL
SELECT Item_Code,Item_Description,UOM
FROM Products
WHERE Item_Description like '%book%'
GROUP BY Item_Code,Item_Description,UOM
HAVING UOM = 'Each'


Hope this will help..
 
Share this answer
 
Comments
viveksri06 23-Mar-12 8:08am    
Thanks Hiren...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900