When to use HAVING clause in a Select Statement?

Asked By 0 points N/A Posted on -
qa-featured

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.

SHARE
Best Answer by Marvin M Calderon
Answered By 5 points N/A #100607

When to use HAVING clause in a Select Statement?

qa-featured

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

Best Answer
Best Answer
Answered By 55 points N/A #100608

When to use HAVING clause in a Select Statement?

qa-featured

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

Related Questions