what is the difference between where clause and having clause

Answers were Sorted based on User's Feedback



what is the difference between where clause and having clause..

Answer / sriram

WHERE clause is used to impose condition on SELECT
statement as well as single row function and is used before
GROUP BY clause where as HAVING clause is used to impose
condition on GROUP Function and is used after GROUP BY
clause in the query

WHERE applies to rows HAVING applies to summarized rows
(summarized with GROUP BY) if you wanted to find the
average salary in each department GREATER than 333 you
would code:

SELECT DEPARTMENT AVG(SALARY)

FROM EMP

WHERE DEPARTMENT > 333

GROUP BY DEPARTMENT

IF you then wanted to filter the intermediate result to
contain departments where the average salary was greater
that 50 000 you would code:

SELECT DEPARTMENT AVG(SALARY)

FROM EMP

WHERE DEPARTMENT > 333

GROUP BY DEPARTMENT

HAVING AVG(SALARY) > 50000.

Where executes first

GROUP BY next

and finally HAVING


Is This Answer Correct ?    9 Yes 0 No

what is the difference between where clause and having clause..

Answer / selvam a

HAVING clause can only compare a built in function but WHERE
clause can compare column name.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

pls explain the precompilation process of cobol-db2 pgm

3 Answers   HCL, IBM,


How do you eliminate duplicate values in db2?

0 Answers  


What is syscat in db2?

0 Answers  


How does DB2 determine what lock-size to use?

2 Answers  


Q1. How will you use two different DB2 qualifiers in a single COBOL program? Suppose we have 2 tables EMP1 and EMP2 with same structure defined in two different DB2 qualifiers QUAL1.EMP1 and QUAL2.EMP2 now during first 15 days we want to use QUAL1.EMP1 and rest of the days QUAL2.EMP2  how will we do this.  We can create a single program and a single load for this program. 

2 Answers   RBS,






What is isolation level?

4 Answers  


How to find the number of rows in db2 tables?

0 Answers  


Can i insert bulk records into a db2 table using qmf of spufi only............!!!

2 Answers  


What type of database is db2?

0 Answers  


What is an alias?

3 Answers  


What is a db2 tablespace?

0 Answers  


wht is d/f between union and joins ?

2 Answers  


Categories