Sql*Plus User’s Guide and Reference


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

Example 6–15
Computing the Same Type of Summary Value on Different Columns
To print the total of salaries and commissions for all sales people, first enter the 
following COMPUTE command:
COMPUTE SUM OF SALARY COMMISSION_PCT ON REPORT
You do not have to enter a BREAK command; the BREAK you entered in 
Example 6–14, "Computing and Printing a Grand Total"
is still in effect. Now, change 
the first line of the select query to include COMMISSION_PCT:

APPEND , COMMISSION_PCT;
Finally, run the revised query to see the results:
/
You can also print multiple summary lines on the same break column. To do so, 
include the function for each summary line in the COMPUTE command as follows:
COMPUTE 
function
LABEL 
label_name
function
LABEL 
label_name
function
LABEL 
label_name
...
OF column ON 
break_column
If you include multiple columns after OF and before ON, COMPUTE calculates and 
prints values for each column you specify.
Example 6–16
Computing Multiple Summary Lines on the Same Break Column
To compute the average and sum of salaries for the sales department, first enter the 
following BREAK and COMPUTE commands:
BREAK ON DEPARTMENT_ID
1* SELECT LAST_NAME, SALARY
LAST_NAME SALARY COMMISSION_PCT
------------------------- ---------- --------------
Russell 14000 .4
Partners 13500 .3
Errazuriz 12000 .3
Cambrault 11000 .3
Zlotkey 10500 .2
---------- --------------
sum 61000 1.5


Defining Page and Report Titles and Dimensions
Formatting SQL*Plus Reports
6-17
COMPUTE AVG SUM OF SALARY ON DEPARTMENT_ID
Now, enter and run the following query:
SELECT DEPARTMENT_ID, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE DEPARTMENT_ID = 30
ORDER BY DEPARTMENT_ID, SALARY;

Download 5.34 Mb.

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




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