SQL Having Clause

0
193

sqltuts

SQL Having Clause

Having clause is used to mention condition in Group based SQL functions, just like WHERE clause. It acts in the same way as does where clause is used:

The syntax for having will be,

Example of HAVING Statement

Consider the following shopping list table.

Sid order_name previous_balance customer
1 ord1 2850 ram
35 ord2 1520 sham
36 ord3 2890 ghanshyam
42 ord4 1780 tom
31 ord5 2220 ram

Suppose we want to find the customer whose previous_balance sum is more than 3000.

We will use the below SQL query for  a given database,

The result will be,

Sid order_name previous_balance customer
11 ord1 2850 ram

 

Previous articleSQL GROUP BY Statement
Next articleHow to Retrieve Data from Session Array Variable in PHP
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.