SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-202
MXCI Examples of SELECT
JOBCODE DEPTNUM (EXPR) (EXPR)
------- ------- ----------- -----------
900 1500 17000.00 17000.00
900 2500 18000.00 18000.00
...
300 3000 19000.00 32000.00
900 2000 32000.00 32000.00
...
300 3200 22000.00 33000.10
420 4000 18000.10 36000.00
...
--- 16 row(s) selected.
Only job codes 300, 420, and 900 are selected. The minimum and maximum
salary for the same job in each department are computed, and the rows are
ordered by maximum salary.
Select from two tables that have been joined by using an INNER JOIN on matching
part numbers:
SELECT OD.*, P.*
FROM sales.odetail OD INNER JOIN sales.parts P
ON OD.partnum = P.partnum;
Order/Num Part/Num Unit/Price Qty/Ord Part/Num
Part Description PRICE Qty/Avail
---------- -------- ------------ ---------- --------
------------------ ------------ -----------
400410 212 2450.00 12 212
PCSILVER, 20 MB 2500.00 3525
500450 212 2500.00 8 212
PCSILVER, 20 MB 2500.00 3525
100210 244 3500.00 3 244
PCGOLD, 30 MB 3000.00 4426
800660 244 3000.00 6 244
PCGOLD, 30 MB 3000.00 4426
... ... ... ... ...
... ... ...
--- 72 row(s) selected.
Select from three tables and display them in employee number order. Two tables
are joined by using a LEFT JOIN on matching department numbers, then an
additional table is joined on matching jobcodes:
SELECT empnum, first_name, last_name, deptname, location,
jobdesc
FROM employee e LEFT JOIN dept d ON e.deptnum = d.deptnum
LEFT JOIN job j ON e.jobcode = j.jobcode
ORDER BY empnum;