SELECT is probably the most frequently used SQL statement. It specifies the table columns from which to select values, the corresponding database (if different from the current default database), and the table or tables to reference within that database.
The SELECT statement further specifies how, in what format, and in what order the system returns the result data.
You can use the following options, lists, and clauses with the SELECT statement to request data from the database. The list is not exhaustive.
- DISTINCT option
- FROM clause
- WHERE clause, including subqueries
- GROUP BY clause
- HAVING clause
- QUALIFY clause
- ORDER BY clause
- CASESPECIFIC option
- International sort orders
- WITH clause
- Query expressions and set operators
A variation is the SELECT INTO statement, which is used in embedded SQL and stored procedures. This statement selects at most one row from a table and assigns the values in that row to host variables in embedded SQL or to local variables or parameters in Teradata stored procedures.