Show TOC Start of Content Area

Syntax documentation SELECT Statement  Locate the document in its SAP Library structure

A SELECT statement allows retrieving data from the database. Technically, it is a query with an optional clause for ordering the results. The query is either a query specification or a union of query specifications. The result of a SELECT statement is a result set.

Syntax

Syntax

<select statement> ::= <query> ( <order by clause> )?.

 

<query>  ::= <query specification>

                    | <query expression>

 

Examples

Example

SELECT * FROM employees

A Simple SELECT Statement. This SELECT statement selects all columns from the table employees.

Example

SELECT empid AS employee_id, last_name,salary

                         FROM employees

                         WHERE salary>5000

                         ORDER BY employee_id

A SELECT Statement. This SELECT statement selects data from the columns empid, last_name and salary from the table employees. The statement selects only the employees whose salary is greater than 5,000. In the result table, the data from the empid column is presented in a column named EMPLOYEE_ID,and the table is sorted by this column in ascending order.

More Information

Query Specification

FROM Clause

Joined Table

Table Reference

WHERE Clause

GROUP BY Clause

HAVING Clause

Select List

UNION

ORDER BY Clause

End of Content Area