ODBC Server Reference Manual

CORE SQL Language
HP NonStop ODBC Server Reference Manual429151-002
3-55
Examples
Examples
The following statement retrieves all rows and all columns from the EMPLOYEE table:
select * from employee
The following statement retrieves all employees in department 1030:
select * from employee
where deptnum = 1030
This statement finds the average salary for each department in the EMPLOYEE table:
select AVG ( salary ) from employee
GROUP BY deptnum ORDER BY deptnum
The preceding syntax diagram shows the entire syntax of the SELECT statement. The
following diagrams show the syntax of each primary clause.
table-reference is:
table-name [ correlation-name ] | [ outer-join-extension ]
outer-join-extension is
{ OJ outer-join } | outer-join
outer-join is:
table-name [ correlation-name ] LEFT [OUTER] JOIN
oj-table-reference
ON search-condition
oj-table-reference is:
table-name [ correlation-name ] | outer-join
sort-specification is:
[ unsigned-integer ]
[ column-identifier [ ASC | DESC ] ]
Note. The braces ( { and } ) in the outer-join-extension in the preceding syntax are not
the usual syntax convention indicating choice, but instead are actual characters that you must
enter.