Having clause:
Ø Having clause is used to filter the group of rows returned in the GROUP BY clause.
Ø Mainly, Aggregate functions are not allowed in the where condition so SQL prefers HAVING CLAUSE for filtering.
Syntax:
Example:
Table: Books
|
Book_Name |
Order_Date |
Orders |
|
SQL |
01-Dec-2000 |
2 |
|
DBMS |
05-Sep-2000 |
3 |
|
PL/SQL |
06-Oct-2000 |
4 |
|
SQL |
09-Sep-2000 |
3 |
|
SQL |
06-Oct-2001 |
2 |
|
DBMS |
22-Jun-2001 |
3 |
|
PL/SQL |
25-Jan-2002 |
3 |
|
SQL |
20-jul-2002 |
4 |
|
DBMS |
09-Nov-2003 |
4 |
Output:
|
Book_Name |
Sum(Orders) |
|
PL/SQL |
7 |
|
DBMS |
10 |
|
SQL |
11 |






No comments:
Post a Comment