what is the difference between where clause and having clause
Answer Posted / 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 |
Post New Answer View All Answers
Before you give the explain statement, what are the prerogatives?
What is the syntax for seeing the columns and data types of a table in the db2 database?
What is scrollable cursor in db2?
What is the maximum number of columns in a db2 table?
What os does db2 run on?
run jcl for cobol+db2 pgm?.. //jobcard //step001 exec pgm=ikjeft01 //systin dd * DSNSYSTEM(--------) RUN PROGRAM(MYPGMNAME) PLAN(-----), LIB(-------), PARMS(------) /* WHAT WILL U GIVE INSIDE THE BRACKETS... WHAT IS PLAN,PACKAGE,BIND?..PLAN N PACAKGES ARE GENERATED BY ?...
What is the use of reorg in db2?
What is the difference between spufi and qmf?
What is performance tuning db2?
Explain in detail about buffer manager and its functionalities?
What is multi row fetch in db2?
What is the difference between dbm cfg and db cfg file in db2 ?
What is a buffer in memory?
B37 abend during spufi?
What is the latest version of ibm db2?