yes. You can use group by and having clauses together. You can say "having clause is child clause of group by clause". That means you can't use having clause with out group by. If you are asked to display department id and total salary of each department then you will write, select department_id, sum(salary) from employees group by department_id; the above statement works happily. But if you are asked to display department id and total salary of each department whose total salary is greater than $50,000 then how will you do that? can we use where clause for this? no. We can not use where clause here. Bacause where clause is meant for filtering records not groups. Here we have to filter groups. The solution to this is having clause. Having clause is used to filter groups. Select department_id, sum(salary) from employees group by department_id having sum(salary) >50000; the above sql filters departments whose total salary is less than $50,000. I hope you are clear with the having clause now.
---james