select Syntax

A simple select statement contains only the select clause; the from clause is almost always included, but is necessary only in select statements that retrieve data from tables.

All other clauses, including the where clause, are optional.

The full syntax of the select statement is in the Reference Manual: Commands.

TOP unsigned_integer lets you limit the number of rows in a result set; specify the number of rows you want to view. TOP is also used in the delete and update commands, for the same purpose.

If the statement includes a group by clause and an order by clause, the group by clause must precede the order by clause.

Qualify the names of database objects if there is ambiguity about the object referred to. If several columns in multiple tables are called “name,” you may need to qualify “name” with the database name, owner name, or table name. For example:

select au_lname from pubs2.dbo.authors

The holdlock, noholdlock, and shared keywords (which are for locking in SAP ASE) and the index clause are described in, Using Locking Commands in the Performance and Tuning Series: Locking and Concurrency Control guide. For information about the for read only and for update clauses, see the declare cursor command in Reference Manual: Commands.

Note: The for browse clause is used only in DB-Library applications. See the Open Client DB-Library/C Reference Manual for details.
Related concepts
Aggregates, Grouping, and Sorting
Databases and Tables
Transactions: Maintain Data Consistency and Recovery
Browse Mode Versus Cursors