Order Of Execution With SQL Server

Kevin Feasel

2017-12-21

Syntax

Andrew Tobin explains the order of how a SQL statement gets processed:

For a particular query you may have the following components and they act in this order:

1 FROM / JOIN
2 WHERE
3 GROUP BY
4 HAVING
5 SELECT
6 ORDER BY
7 TOP / OFFSET-FETCH

Read on for more details.  This is why, for example, you can use an aliased column or calculation in the ORDER BY clause but not in the WHERE clause.

Related Posts

What’s In SQL Server 2019 CTP 2.0?

Aaron Bertrand gives us the highlights: Certificate Management in Config Manager View and validate all of your certificates from a single interface, and manage and deploy certificate changes across all of the replicas in an Availability Group or all of the nodes in a Failover Cluster Instance. Built-in data classification A new ADD SENSITIVITY CLASSIFICATION statement helps you identify and […]

Read More

Multiple Mentions Of A Column In An UPDATE Statement

Doug Lane walks us through various scenarios with updates including the same column multiple times: An application developer came to me with this question recently: “Can I use the same column twice in a SQL UPDATE statement?” Yes and no. It depends on what you mean by “use”. Read on to see what Doug means.

Read More

Categories

December 2017
MTWTFSS
« Nov Jan »
 123
45678910
11121314151617
18192021222324
25262728293031