Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me in which order SQL query is executed?

1 Answer

0 votes
by (119k points)

In the below SQL query, the query execution happens in the following order:

  • FROM and JOINs
  • WHERE
  • GROUP BY
  • HAVING
  • SELECT
  • DISINCT
  • ORDER BY
  • LIMIT or OFFSET

SELECT DISTINCT column, AGG_FUNC(column_or_expression), …

FROM mytable

    JOIN another_table

      ON mytable.column = another_table.column

    WHERE constraint_expression

    GROUP BY column

    HAVING constraint_expression

    ORDER BY column ASC/DESC

    LIMIT count OFFSET COUNT;

If you want to learn SQL and writing SQL queries, I recommend this SQL Training course by Intellipaat that provides Instructor-led training, certification, and also job assistance.

Related questions

0 votes
1 answer
asked May 4, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked May 5, 2020 in SQL by Sudhir_1997 (55.6k points)

Browse Categories

...