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 |
When the like statement is used?
What is the database descriptor?
How to design maps
My DB2 program first read the data from a file and then it look into a table with the data it got from the file.If we did not bind the program , should the file read before SQL execution be success??
What are db2 error codes -305 and -407. What is the difference between these 2 error codes ?
What does CURRENTDATA option in bind indicate
What is referential integrity?
How can you classify the locks in db2?
What is the syntax for FETCH in DB2 ?
What is an alias?
if there is a table with huge number of records and if i want to extract only first 3 records from the table, what query i have to provide to retreive first 3 records
What is tablespace?