Databases Reference
In-Depth Information
SELECT column_list [ALL | DISTINCT]
[TOP expression [PERCENT] [WITH TIES]]
[INTO table_name ]
FROM source [[INNER|OUTER|CROSS] JOIN]
WHERE search_condition
[ORDER BY order_expression [ASC] | [DESC]]
[GROUP BY [ALL] group_expression ]
[HAVING search_condition ]
This is still not the complete SELECT statement syntax. There are some fea-
tures and functionality supported by the SELECT statement that are beyond the
scope of this text. A discussion of some of the remaining keywords and options,
at this point, might do more to confuse than to enlighten.
Because of this, you might see uses of the SELECT statement that include
keywords not presented here, such as the FOR XML clause that is used to return
database table data formatted as an XML document fragment, a portion of an
XML document containing data organized in a hierarchical fashion. Refer to the
Books Online that install with SQL Server and the Microsoft Developer Network
(MSDN) Web site for more complete information on advanced SELECT statement
syntax (in SQL Server) and keywords not covered as part of this text.
Table 7-1 has a brief explanation of the additional keywords introduced here.
You will get a chance to see these keywords used in this chapter.
Table 7-1: SELECT Statement Keywords
Keyword
Description
ALL
Default option, specifying that all results, including
duplicate rows, are returned.
DISTINCT
Limits result set to distinct (non-duplicate) rows only.
TOP
Used to limit the result set to a set number or percentage
of the rows returned.
INTO
Create the table specified as table_name based on the
result.
JOIN
Combines two or more data sources in a single statement
based on the values in specific joining columns.
ORDER BY
Sets the order in which rows are returned.
GROUP BY
Used to group rows by column value for generation of
aggregate value results.
HAVING
Used with the GROUP BY statement to filter the result.
Search WWH ::




Custom Search