NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
T-10
Examples—TOTAL
Examples—TOTAL
The following example selects data, specifies a detail line, and specifies a column to
total:
>> SELECT * FROM PERSNL.EMPLOYEE WHERE DEPTNUM = 3000;
S> DETAIL EMPNUM, SALARY;
S> TOTAL SALARY;
The output might look like the following:
EMPNUM SALARY
------ -----------
1 175500.00
...
-----------
-----------
489075.00
The following example selects data, uses NAME to assign names to the last two
columns in the report, and then specifies totals for those columns:
>> SELECT PARTNUM, AVG(QTY_ORDERED),
AVG(UNIT_PRICE*QTY_ORDERED)
+> FROM SALES.ODETAIL
+> GROUP BY 1
+> ORDER BY 1;
S> NAME COL 2 AVGORD;
S> NAME COL 3 AVGPR;
S> TOTAL AVGORD, AVGPR;
The output might look like the following:
PARTNUM AVGORD AVGPR
------- ------------------- --------------------
...
7102 55 687.50
7301 3 4807.99
------------------- --------------------
------------------- --------------------
1480 55683.59