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 database alias db2?
In cursor program-1 can we create another cursor program-2 inside the cursor program-1.If yes how/no why ?
what is REORG? what is the use?
How does coalesce work?
What is role in db2?
what is the difference between where clause and having clause
What are the various locks available?
what is the difference between declaring the cursor in WS section and Procedure division?
What is the difference between IN subselects and EXISTS subselect?
Describe what a storage group(STOGROUP) is?
What is cloudant database?
How can we read records for specific member in CL? AND rpg?