SQL/MX 2.x Reference Manual (G06.24+, H06.03+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual523725-004
2-203
MXCI Examples of SELECT
where main.iss_eligible='Y'
ORDER BY 1 ascending for browse access;
For more information about the effect of UNION on SELECT statements, including its
effect on performance, see the SQL/MX Query Guide.
MXCI Examples of SELECT
Retrieve information from the EMPLOYEE table for employees with a job code
greater than 500 and who are in departments with numbers less than or equal to
3000, displaying the results in ascending order by job code:
SELECT jobcode, deptnum, first_name, last_name, salary
FROM persnl.employee
WHERE jobcode > 500 AND deptnum <= 3000
ORDER BY jobcode
READ UNCOMMITTED ACCESS;
JOBCODE DEPTNUM FIRST_NAME LAST_NAME SALARY
------- ------- --------------- ----------- ----------
600 1500 JONATHAN MITCHELL 32000.00
600 1500 JIMMY SCHNEIDER 26000.00
900 2500 MIRIAM KING 18000.00
900 1000 SUE CRAMER 19000.00
. . .
In this example, because of READ UNCOMMITTED access, the query does not
wait for other concurrent processes to commit rows.
Display selected rows grouped by job code in ascending order:
SELECT jobcode, AVG(salary)
FROM persnl.employee
WHERE jobcode > 500 AND deptnum <= 3000
GROUP BY jobcode
ORDER BY jobcode;
JOBCODE EXPR
------- ----------------------
600 29000.00
900 25100.00
--- 2 row(s) selected.
This select list contains only grouping columns and aggregate functions. Each row
of the output summarizes the selected data within one group.
Select data from more than one table by specifying the table names in the FROM
clause and specifying the condition for selecting rows of the result in the WHERE
clause:
SELECT jobdesc, first_name, last_name, salary
FROM persnl.employee E, persnl.job J
WHERE E.jobcode = J.jobcode AND
E.jobcode IN (900, 300, 420);