1.

Discuss the significance of having clause with group by statement with suitable example.

Answer»

Sometimes we do not want to see the whole output produced by a statement with Group By clause. We want to see the output only for those groups which satisfy some condition. It means we want to put some condition on individual groups (and not on individual records). A condition on groups is applied by Having clause.

For example consider the following query:

select Acc_No, sum(Amount) from Customer c, Transaction t where c.Acc_No=t.Acc_No group by c.Acc_No having Transaction_Type="Credit"; 

This query will create account number wise groups and instead of displaying the total amount of all type of transactions, it will only display the total of credit transactions only.



Discussion

No Comment Found

Related InterviewSolutions