Difference between a HAVING CLAUSE and a WHERE CLAUSE?

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE in SQL Statements?


Views: 13706 | Community Opinion: 13

Tags..  SQL SERVER  DBA  Database Developer  SQL Queries

Bookmark this page..



Ask a New Question Go to Home

Community Opinion/Answers
 
Param Said..

Both HAVING and WHERE clause used for specifying the search condition in SQL queries.

HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query.

WHERE Clause can be used for specifying the search criteria in SELECT, DELETE, UPDATE statements.




sreenivas Said..

we can't use Having with out GROUP BY function




mohan Said..

Good.




abc Said..

we can use HAVING without GROUP BY().




PARASH Said..

Having can be use only with GROUP BY function other wise it will give error as ORA-00979: not a GROUP BY expression




Ravi Kumar L Said..

I can say that "having" clause can only be used with group by function. But "where" clause can be used in any queries which require to filter the data. Thank you...............................................................................................................




Rahul Singh Said..

This is one of the best answer so far, I have read online. No crap, just useful information. Very well presented. I had found good collection of Ms-SQL server interview question and answer over internet. Here I am sharing link of that post...
http://www.mindstick.com/Interview/1216/Difference%20between%20a%20quot%20where%20quot%20clause%20and%20a%20quot%20having%20quot%20clause




xyz Said..

to abc r u mad mdh we cnt use having clause without group by......................................................................................................................................................................................................................................................................................................................................................................................




bhanchod Said..

fuck you all ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................




Bharti Said..

To view difference between where and having class click Where and Having
and for some more differences kindly visit Sql Basic




GRSRaja Said..

Where clause fetch the value from the table but having fetch the values from grouped function doesn't fetch from table... It is a major different...............................................................................................................................................................




foxin Said..

canada goose jacket have a wonderful amount of purchasers. They may be manufactured having a fluffy inner coating to assist keep ones body warm as well as have deep pockets and in addition hardwearing.To satisfy the winter season of 2011, canada goose sale shops hold an activity of discount rates at the earliest. We offer comprehensive collections of Canada Goose apparel, this kind of as Canada Goose coats, Canada Goose Men Vest and Canada Goose guys jackets, etcetera. Welcome to Canada Goose Outlet on the net shop, the very best and least expensive Canada goose jacketsgoods factory shop, free shipping to all globe. In addition, True Religion supplies such huge quantity youll uncover jeans for each occasion. Aside from you acquire a person set of two and uncomplicated True Religion jeans, Canada Goose Men Down Jackets and in addition the developer jeans which will perfectly complement your glimpse and model.




abhijit kumbhar Said..

1. The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause.
2. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping.
3. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions.






What do you think? Add your opinion/answer
*Name
*your opinion/answer: