SQL Having Clause



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


Facebook Comments

Leave a Reply

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