Database Management System

Oracle SQL Interview Questions

Pinterest LinkedIn Tumblr

What is the difference between WHERE clause and HAVING clause

WHERE clause can only be applied on a static non-aggregated column whereas we will need to use HAVING for aggregated columns

SELECT * FROM HR.employees WHERE EMPLOYEE_ID > 200
 
SELECT dept.DEPARTMENT_NAME, avg(emp.salary) AVG_SAL
FROM HR.departments dept, HR.employees emp
WHERE dept.DEPARTMENT_id = emp.DEPARTMENT_id (+)
GROUP BY dept.DEPARTMENT_NAME
HAVING AVG(emp.salary) > 80
1 2 3 4 5 6 7 8 9 10

Write A Comment