B.2. SELECT GENERAL FORM

Before looking at GROUP BY, let's recall the general form of the SELECT statement:

					SELECT [ DISTINCT ]{ select-item-list | * }
    FROM table-or-view-list
    [ WHERE search-condition  ]
    [ GROUP BY column-reference-list ]
    [ HAVING search-condition ]
    [ ORDER BY sort-item-list ]

Consider the flow, shown in Figure B-2, from base tables to a series of virtual tables involved in a SELECT statement.

Figure B-2. The flow in a SELECT statement

The FROM clause picks which tables and views will be worked on, ultimately going down to all base tables where the actual data is located.

These tables are input to the WHERE clause that then works ...

Get Transact-SQL Desk Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.