No of visitors who read this post: 189
Category: DB2
Type: Question
Author: Jesdale
No votes yet

Hi there experts.

I know basic queries but Im having a confusion on this matter.

Ive been mostly using WHERE clause in a select statement but Im not quite sure when to use HAVING.

When should I use this clause and not WHERE clause?

I would be very happy if youll help me out on this.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

#

WHERE CLAUSE can not be used with aggregate function in SQL functions like AVG, MIN, MAX, SUM, COUNT etc.To solve this problem in SQL HAVING CLAUSE was added

Execution is not possible in WHERE clause It is only Possible in HAVING clause that is why it been added Take a Look

SELECT column_name, aggregate_function(column_name)

FROM table_name

WHERE column_name operator value

GROUP BY column_name

HAVING aggregate_function(column_name) operator value

#

Hello Jesdale,

                   It is just a filter that can help you in making your data in a different form so that you can get some specific results from your query in your database. If you want to know about these things then i am attaching a link in that comment i think that you can get  a clear idea that what there two clauses do in data base. And also there is example that how you can use that thing in your data base. All you need is to see the link you can get each and every thing in a detailed form in that website about any or the thing related to SQL server.

http://www.tutorialspoint.com/sql/sql-having-clause.htm