SELECT
statements retrieves rows from the database and enables the selection
of one or many rows or columns from one or many tables. They do not
modify data in any way and are simply a method of looking at the data
stored in a single table or in many related tables.
SELECT
statements do not generate a transaction in Microsoft SQL Server
either.
Syntax
of the SELECT statement
SELECT
[
ALL | DISTINCT ]
[TOP
( expression ) [PERCENT]
[
WITH TIES ]
]
<
select_list
>
[
INTO new_table ]
[FROM
{table_name | view_name}[(optimizer_hints)]
[[,
{table_name2 | view_name2}[(optimizer_hints)]
[...,
{table_name16 | view_name16}[(optimizer_hints)]]]
[WHERE
<search_condition>]
[GROUP
BY clause]
[HAVING
<search_condition>]
[ORDER
BY clause]
[COMPUTE
clause]
[FOR
BROWSE]
Logical Processing Order of the SELECT statement
The
order execution of the clauses in the SELECT statement is
significant. Given below is the order in which SQL clauses get
executed:
- FROM
- ON
- JOIN
- WHERE
- GROUP BY
- WITH CUBE or WITH ROLLUP
- HAVING
- SELECT
- DISTINCT
- ORDER BY
- TOP
No comments:
Post a Comment