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 |
What is the database descriptor?
Can we declare cursor in Procudere division or open the cursor in the Working storage section. Is there any particular rules in the usage of cursors lifecycle
Where is the access path logic created by the DB2 Optimizer stored?
How to execute stored procedure in db2 command editor?
What does the sqlcode of -818 pertain to?
What is the COBOL picture clause for a DB2 column defined as DECIMAL(11,2)?
What is the significance of the CURSOR WITH HOLD clause in a cursor declaration?
What is buffer pool in the db2 database?
how do we solve soc 7 and soc4 ?
What is scrollable cursor in db2?
What is declare cursor?
by using cursors , we can access particular records from the table based on some condition, i want to delete those selected records, how can we write a query for this in the program?