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

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-204
C Examples of SELECT
GROUP BY OD.ordernum;
ORDERNUM (EXPR)
---------- ---------------------
200490 1030.00
300350 71025.00
300380 28560.00
--- 3 row(s) selected.
The price for the total quantity ordered is computed for each order number.
Show employees, their salaries, and the percentage of the total payroll that their
salaries represent. Note the subquery as part of the expression in the select list:
SELECT empnum, first_name, last_name, salary,
CAST(salary * 100 / (SELECT SUM(salary) FROM persnl.employee)
AS NUMERIC(4,2))
FROM persnl.employee
ORDER BY salary, empnum;
Employee/Number First Name Last Name
salary (EXPR)
--------------- --------------- --------------------
----------- -------
209 SUSAN CHAPMAN
17000.00 .61
235 MIRIAM KING
18000.00 .65
224 MARIA JOSEF
18000.10 .65
...
23 JERRY HOWARD
137000.10 4.94
32 THOMAS RUDLOFF
138000.40 4.98
1 ROGER GREEN
175500.00 6.33
...
--- 62 row(s) selected.
C Examples of SELECT
Use a single-row SELECT statement:
EXEC SQL
SELECT LAST_NAME, FIRST_NAME INTO :hv_lname, :hv_fname
FROM EMPLOYEE WHERE EMPNUM = 1234;
Use an indicator variable:
EXEC SQL BEGIN DECLARE SECTION;
...
short ihv_salary; /* Indicator variable */
float hv_salary;
EXEC SQL END DECLARE SECTION;