Sql*Plus User’s Guide and Reference


Table 6–1 Compute Functions


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

Table 6–1
Compute Functions
Function...
Computes the...
SUM
Sum of the values in the column.
MINIMUM
Minimum value in the column.
MAXIMUM
Maximum value in the column.
AVG
Average of the values in the column.
STD
Standard deviation of the values in the column.
VARIANCE
Variance of the values in the column.
COUNT
Number of non-null values in the column.
NUMBER
Number of rows in the column.
break on DEPARTMENT_ID page nodup
on JOB_ID skip 1 nodup


Clarifying Your Report with Spacing and Summary Lines
6-14
SQL*Plus User's Guide and Reference
To compute the sum of salaries for departments 10 and 20 without printing the 
compute label:
COLUMN DUMMY NOPRINT;
COMPUTE SUM OF SALARY ON DUMMY;
BREAK ON DUMMY SKIP 1;
SELECT DEPARTMENT_ID DUMMY,DEPARTMENT_ID, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000
ORDER BY DEPARTMENT_ID;
To compute the salaries just at the end of the report:
DEPARTMENT_ID JOB_ID LAST_NAME SALARY
------------- ---------- ------------------------- ----------
20 MK_MAN Hartstein 13000
************* ********** ----------
sum 13000
DEPARTMENT_ID JOB_ID LAST_NAME SALARY
------------- ---------- ------------------------- ----------
80 SA_MAN Russell 14000
Partners 13500
************* ********** ----------
sum 27500
DEPARTMENT_ID JOB_ID LAST_NAME SALARY
------------- ---------- ------------------------- ----------
90 AD_PRES King 24000
AD_VP Kochhar 17000
De Haan 17000
************* ********** ----------
sum 58000
6 rows selected.
DEPARTMENT_ID LAST_NAME SALARY
------------- ------------------------- ----------
20 Hartstein 13000
----------
13000
80 Russell 14000
80 Partners 13500
----------
27500
90 King 24000
90 Kochhar 17000
90 De Haan 17000
----------
58000
6 rows selected.


Clarifying Your Report with Spacing and Summary Lines
Formatting SQL*Plus Reports
6-15
COLUMN DUMMY NOPRINT;
COMPUTE SUM OF SALARY ON DUMMY;
BREAK ON DUMMY;
SELECT NULL DUMMY,DEPARTMENT_ID, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000
ORDER BY DEPARTMENT_ID;
When you establish the format of a NUMBER column, you must allow for the size of 
the sums included in the report.

Download 5.34 Mb.

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




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