Use a
SELECT statement to specify criteria for returning rows from
a database table.
Before you begin
The SELECT statement
is made up of several clauses including the
SELECT clause, FROM clause, WHERE clause, ORDER BY clause, GROUP BY
clause
and HAVING clause.
Restriction: You cannot create
a query
by using a view that is derived from a user-defined function.
Prerequisite: Before
you specify a SELECT statement, create the
statement in the SQL Query Builder.
About this task
To specify
a SELECT statement in the SQL Query Builder:
- Add one or more tables to the
statement.
- Optional: Create
one or more join conditions.
- Optional:
To eliminate all but one of each set of duplicate rows
of the final results table, select the DISTINCT check
box in the Design pane.
- To specify the columns
to use in the statement:
- Click the Columns tab
in the Design pane.
- In the first available
cells under the Column heading,
select one or more columns to use in the statement, or type one or
more expressions,
or both. To use a wizard to create a complex expression, click Expression
Builder at the end of the list of columns in a cell, and
then
press Enter.
- Optional: Type an alias
for the column or expression. You cannot use any spaces
in the alias. When you run the SQL statement,
the alias appears in the results table instead of the column or expression
name.
- To show a column or expression
in the results table when you
run the statement, select its Output check
box. To
use a column or expression in the statement, but not use it when you
run the
statement, clear its Output check box. For
example, you might want to do this if you are defining an ORDER BY
clause
on a column and you still want to show all columns in the result set:
SELECT
* FROM DEPT ORDER BY DEPT.NUMBER.
- Optional: To specify the order of the rows in the results
table, create an ORDER BY clause for
the SELECT statement.
- Optional: To specify
which rows of the database table to return
in the results table, define conditions for
the SELECT statement. If you do not specify a condition,
all rows
of the target database table are returned.
- Optional:
To define groupings for the statement, create
GROUP BY clauses.
- Run the statement. The
output is shown in the SQL Results view.