Was this helpful?
SELECT (interactive)
Valid in: SQL, DBProc, TblProc, OpenAPI, ODBC, JDBC, .NET
The SELECT (interactive) statement returns values from tables or views.
The SELECT (interactive) statement has the following format:
[WITH common_table_expression]
SELECT [FIRST rowCount] [ALL | DISTINCT] * | expression [AS result_column]
              {, expression [[AS] result_column]}
              [FROM from_source {, from_source}
              [WHERE search_condition]
              [GROUP BY [ALL | DISTINCT] grouping element {,grouping element}]
              [HAVING search_condition]
              {UNION [ALL] | INTERSECT | EXCEPT]
              (select)}
              [ORDER BY ordering-expression [ASC | DESC]
                            {, ordering-expression [ASC | DESC]}];
                                [NULLS {FIRST | LAST}]];
              [LIMIT n] [OFFSET n]
              [FETCH FIRST|NEXT n ROWS|ROW ONLY]
              [WITH options]
The SELECT (interactive) statement returns values from one or more specified tables or views, in the form of a single result table. Using the various clauses of the SELECT statement, the following can be specified:
Criteria for the values to be returned in the result table
How the values in the result table are to be sorted and grouped
In interactive SQL (ISQL) the results of a query are displayed on your terminal. In embedded SQL (ESQL), results are returned in host language variables. For details about using the SELECT statement in ESQL, see SELECT (embedded).
The SELECT statement can be preceded by a common table expression (see WITH (common_table_expression)).
Tip...  User consumption of computing resources can be restricted during queries (selects) using the GRANT statement. Specifically, limits can be specified for I/O and for the number of rows returned. If the DBMS query optimizer estimates that a select exceeds the specified limits, the query is not executed. For details, see GRANT (privilege).
Note:  If II_DECIMAL is set to comma, you must follow any comma required in SQL syntax (such as a list of table columns or SQL functions with several parameters) by a space. For example:
SELECT col1, IFNULL(col2, 0), LEFT(col4, 22) FROM version;
The following sections describe the clauses of the SELECT statement, explain how to create simple queries, and explain how the results of a query are obtained.
Last modified date: 04/03/2024