How the SQL SELECT Query is exceuted in Oracle Consider the following SQL Query SELECT deptno, sum(sal) total_salary FROM emp WHERE deptno <> 40 GROUP BY deptno HAVING SUM(sal) > 5000 ORDER BY total_salary; Result will be something like DEPTNO TOTAL_SALARY 10 5500 20 7150 30 9500 This is how the query will be executed in Oracle Server from emp This will be exceuted first, as we want to get data from the emp table. where deptno <> 40 This will filter out the result where no record has deptno 40. group by deptno This will group the result into groups of deptnos. having sum(sal) > 5000 This will eliminated the groups that are having total_salary less than or equal to 5000 select deptno, sum(sal) This will fetch the deptno and sum the sal column based on the groups from the result set. order by total_salary This will sort the result by the total_salary in ascending order