Interviews11 answers
What is the order of a SQL Query execution?
11 Answers
1.FROM
2.ON
3.JOIN
4.WHERE
5.GROUP BY
6.WITH CUBE or WITH ROLLUP
7.HAVING
8.SELECT
9.DISTINCT
10.ORDER BY
1.TOP
Suresh KumarPosted Nov 7, 2017, 8:16 PM EST
1.FROM
2.ON
3.JOIN
4.WHERE
5.GROUP BY
6.WITH CUBE or WITH ROLLUP
7.HAVING
8.SELECT
9.DISTINCT
10.ORDER BY
1.TOP
Suresh KumarPosted Nov 7, 2017, 8:16 PM EST
1.FROM
2.ON
3.JOIN
4.WHERE
5.GROUP BY
6.WITH CUBE or WITH ROLLUP
7.HAVING
8.SELECT
9.DISTINCT
10.ORDER BY
1.TOP
Suresh KumarPosted Nov 7, 2017, 8:16 PM EST
"SQL has no order of execution. Is a declarative language. The optimizer is free to choose any order it feels appropriate to produce the best execution time. Given any SQL query, is basically impossible to anybody to pretend it knows the execution order.
Guest UserPosted Sep 14, 2017, 6:54 PM EDT
The order of a SQL Query execution as per below :
1. FROM
2. ON
3. OUTER
4. WHERE
5. GROUP BY
6. CUBE or ROLLUP
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP
Upendra Pratap ShahiPosted Sep 12, 2017, 8:34 AM EDT
Hi ,
Order clause is used to sort the data in descending order and ascending order .
Here is syntax:
SELECT column-list
FROM table_name
[WHERE condition]
[ORDER BY column1, column2, .. columnN] [ASC | DESC];
Gajendra SinghPosted Sep 5, 2017, 4:46 AM EDT
FROM
ON
JOIN
WHERE
GROUP BY
WITH CUBE or WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
TOP
Raj KumarPosted Jun 6, 2017, 12:21 PM EDT
the order of a SQL Query execution
1. FROM
2. ON
3. OUTER
4. WHERE
5. GROUP BY
6. CUBE or ROLLUP
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP
Vinod KakadePosted May 12, 2017, 3:17 AM EDT
1) from
2) on
3) Join
4) where
5) Group by
6) Having
7) select
8) Distinct
9) Order by
10) Top
vinod kumarPosted Apr 5, 2017, 6:18 AM EDT
FROM
ON
JOIN
WHERE
GROUP BY
WITH CUBE or WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
TOP
Rakesh SinghPosted Mar 28, 2017, 8:18 AM EDT
We use SELECT statement to retrieve data from SQL.
Generally we type T-SQL clauses in below order:
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
But the logical query processing order is different.
FROM
WHERE
GROUP BY
HAVING
SELECT
ORDER BY
For example -
If we want return all employees from deptno 30.
SELECT ename,sal FROM emp WHERE deptno=30 ORDER BY ename
When it goes to SQL, it executes as below
FROM emp
WHERE deptno=30
SELECT ename,sal
ORDER BY ename
Each execution phase operates on one or more tables (if JOIN involved) as inputs and returns a virtual table as output. The output table of one phase is considered the input to the next phase.
Santosh Kumar AdidawarpuPosted Feb 11, 2017, 7:06 AM EST







