Which is more efficient('WHERE" or "HAVING") in SQL ?

Showing Answers 1 - 8 of 8 Answers

chitra

  • Sep 8th, 2006
 

Both are having their importance based on their usage. For eg - If u r using "GROUP BY" clause and also want to check some conditon based on this , then u must use HAVING , else for a simple condition checking u can use WHERE.

For eg. -

select emp.deptno,sum(emp.sal)
from emp
where emp.comm is not null
group by emp.deptno
having sum(emp.sal)<2000;

lalita.p

  • Sep 18th, 2006
 

Chitra is Right.Both Having and Group by clause have their ow importance. mostly where clause is used to access necessary data from database which improves query performance while group by clause is best suited for creating the result.

  Was this answer useful?  Yes

Sunil

  • Sep 25th, 2006
 

I think where clause is more important than having clause.Bcz it may possible that we can manage without using having clause,but without select,insert,where,create it is impossible to work on sql. this is just the basic term like +,-,*,/ in mathematics.

Without these maths is impossible and without these clause sql is impossible

  Was this answer useful?  Yes

mamathi

  • Oct 27th, 2006
 

we can use where clause for single function only. haveing clause we can use more then one function in a clause.exselect * from table namewhere salary > 10000;ex havingselect *from table namehaving salary < max(salary);in the having clause we have used two functions one is < onather one is max;we can't use in where clause.we can use only single function in where clausei think it's right

  Was this answer useful?  Yes

Hi Frienz...According to me WHERE and HAVING both are equally important..WHERE is used for condition on a single row and it comes before group by clause...whereas HAVING is used with GROUP BY alwayz...HAVING works on a group whereas WHERE works on a single record or particular records...so they are equally important whether its HAVING or WHERE but if we compare HAVING is slower than where because HAVING works for a group..Thanx

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions