what is the difference between where clause and having clause
Answers were Sorted based on User's Feedback
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 |
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 |
Why PS file called Physical seqential file?How to sore data in sequential file and ESDS file? What is the use of DBRM,PLAN,package and Collection.
What is the difference between primary key & unique index ?
How do you Load a table ?? and what is Load replace ?
Following a db2 update statement, what is the quickest way to compute the total number of updated rows?
What is the meaning concurrency in the db2 database?
what is SMP/E? and what are the major steps of it? thanks...
What are the disadvantages of PAGE level lock?
Suppose pgm A calling Pgm B .Pgm B has some Db2 program. at the time of compilation should plan and package will be created for both A and B or only B? What is the concept?
What is a PLAN table? How will you use it? Give the various fields of PLAN table?
How to take backup of table in db2?
In a DB2-CICS program which is acts as co-ordinator and which is participant?
Is db2 relational database?