Order of Excution

You might also like

You are on page 1of 1

-------------------------** order of excution **------------------------------

In SQL, the order of execution of a query is determined by the logical query


processing phase.
The SQL query is logically processed in the following order:

1. FROM clause:
- This is where the tables involved in the query are specified.

2. JOIN clause:
- If there are multiple tables in the FROM clause and they are joined, the join
conditions
are applied in this phase.

3. WHERE clause:
- The WHERE clause filters rows based on specified conditions.

4. GROUP BY clause:
- If a GROUP BY clause is present, the rows are grouped based on the specified
columns.

5. HAVING clause:
- If a HAVING clause is present, it filters groups based on specified
conditions.

6. SELECT clause:
- The SELECT clause determines which columns are included in the result set.

7. DISTINCT:
- If the DISTINCT keyword is used, duplicate rows are eliminated.

8. ORDER BY clause:
- The ORDER BY clause is applied to sort the result set based on specified
columns.

9. LIMIT/OFFSET or FETCH/FIRST:
- If there is a LIMIT/OFFSET or FETCH/FIRST clause, it limits the number of rows
returned or
specifies the starting point.

You might also like