The SELECT statement forms the core data retrieval operation in the declarative Structured Query Language.
Declarative languages allow analysts to describe what data they want, leaving execution strategies to the database engine.
When querying, the FROM clause identifies the target table, establishing the working dataset for the query.
Specifying explicit column names in the SELECT clause is a best practice known as column projection.
Column projection reduces network bandwidth and memory overhead by avoiding the transfer of unneeded attributes.
Using SELECT * requests all columns defined in the table schema, which is convenient during early exploration.
However, using SELECT * in production queries is fragile, because table schema changes can break downstream pipelines.
The AS keyword assigns aliases to columns, renaming output fields for clearer reporting and dashboard integration.
SELECT can also evaluate mathematical expressions, such as calculating profit by subtracting cost from revenue directly.
Built-in scalar functions allow text formatting, date parsing, and numerical rounding during row projection.
The DISTINCT keyword eliminates duplicate rows from the final result set, returning only unique value combinations.
Under the hood, the query optimiser parses the statement, constructs an execution plan, and requests blocks from storage.
Although SELECT appears first in SQL syntax, the database engine actually processes the FROM clause before projecting columns.
Understanding this internal order of operations helps analysts write efficient queries that leverage database indexes.
A common error is attempting to filter rows using aliases created within the same SELECT statement, which fails in WHERE clauses.