Sql*Plus User’s Guide and Reference


Computing Summary Lines at the End of the Report


Download 5.34 Mb.
Pdf ko'rish
bet91/103
Sana04.08.2023
Hajmi5.34 Mb.
#1665146
1   ...   87   88   89   90   91   92   93   94   ...   103
Bog'liq
E18404-12

Computing Summary Lines at the End of the Report
You can calculate and print summary lines based on all values in a column by using 
BREAK and COMPUTE in the following forms:
BREAK ON REPORT
COMPUTE function LABEL 
label_name
OF 
column
column
column
... ON REPORT
Example 6–14
Computing and Printing a Grand Total
To calculate and print the grand total of salaries for all sales people and change the 
compute label, first enter the following BREAK and COMPUTE commands:
BREAK ON REPORT
COMPUTE SUM LABEL TOTAL OF SALARY ON REPORT
Next, enter and run a new query:
SELECT LAST_NAME, SALARY 
FROM EMP_DETAILS_VIEW
WHERE JOB_ID='SA_MAN';
To print a grand total (or grand average, grand maximum, and so on) in addition to 
subtotals (or sub-averages, and so on), include a break column and an ON REPORT 
DEPARTMENT_ID LAST_NAME SALARY
------------- ------------------------- ----------
20 Hartstein 13000
80 Russell 14000
80 Partners 13500
90 King 24000
90 Kochhar 17000
90 De Haan 17000
----------
98500
6 rows selected.
LAST_NAME SALARY
------------------------- ----------
Russell 14000
Partners 13500
Errazuriz 12000
Cambrault 11000
Zlotkey 10500
----------
TOTAL 61000


Clarifying Your Report with Spacing and Summary Lines
6-16
SQL*Plus User's Guide and Reference
clause in your BREAK command. Then, enter one COMPUTE command for the break 
column and another to compute ON REPORT:
BREAK ON break_column ON REPORT
COMPUTE function LABEL label_name OF column ON break_column
COMPUTE function LABEL label_name OF column ON REPORT
Computing Multiple Summary Values and Lines
You can compute and print the same type of summary value on different columns. To 
do so, enter a separate COMPUTE command for each column.

Download 5.34 Mb.

Do'stlaringiz bilan baham:
1   ...   87   88   89   90   91   92   93   94   ...   103




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling