Pages

Monday, November 30, 2009

Where Vs Having

WHERE

HAVING

1

It is used for restricting rows from table.

It is used for restricting rows which are Grouped.

2

No need to use Group by clause when you are using Where clause.

You have to use Group by Clause When you are using Having Clause.

3

Example :

SELECT ENAME,SALARY

FROM EMP

WHERE SALARY>10000

It returns all employee whose salary > 10000

SELECT DEPTNO,SUM(SALARY)

FROM EMP

GROUP BY DEPTNO

HAVING SUM(SALARY)>10000

It returns all department whose total salary > 10000

0 comments:

Post a Comment