Sql*Plus User’s Guide and Reference


Clarifying Your Report with Spacing and Summary Lines


Download 5.34 Mb.
Pdf ko'rish
bet85/103
Sana04.08.2023
Hajmi5.34 Mb.
#1665146
1   ...   81   82   83   84   85   86   87   88   ...   103
Bog'liq
E18404-12

Clarifying Your Report with Spacing and Summary Lines
When you use an ORDER BY clause in your SQL SELECT command, rows with the 
same value in the ordered column (or expression) are displayed together in your 
output. You can make this output more useful to the user by using the SQL*Plus 
BREAK and COMPUTE commands to create subsets of records and add space or 
summary lines after each subset.
The column you specify in a BREAK command is called a break column. By including 
the break column in your ORDER BY clause, you create meaningful subsets of records 
in your output. You can then add formatting to the subsets within the same BREAK 
command, and add a summary line (containing totals, averages, and so on) by 
specifying the break column in a COMPUTE command.
SELECT DEPARTMENT_ID, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE SALARY > 12000
ORDER BY DEPARTMENT_ID;
To make this report more useful, you would use BREAK to establish DEPARTMENT_
ID as the break column. Through BREAK you could suppress duplicate values in 
DEPARTMENT_ID and place blank lines or begin a new page between departments. 
You could use BREAK in conjunction with COMPUTE to calculate and print summary 
lines containing the total salary for each department and for all departments. You 
LAST_NAME JOB_TITLE CITY
------------------------- -------------------- --------
King President Seattle
Kochhar Administration Vice Seattle
President
-------------------------------------------------------
De Haan Administration Vice Seattle
President
-------------------------------------------------------
Russell Sales Manager Oxford
Partners Sales Manager Oxford
Hartstein Marketing Manager Toronto
6 rows selected.
DEPARTMENT_ID LAST_NAME SALARY
------------- ------------------------- ----------
20 Hartstein 13000
80 Russell 14000
80 Partners 13500
90 King 24000
90 Kochhar 17000
90 De Haan 17000
6 rows selected.


Clarifying Your Report with Spacing and Summary Lines
6-10
SQL*Plus User's Guide and Reference
could also print summary lines containing the average, maximum, minimum, 
standard deviation, variance, or row count.

Download 5.34 Mb.

Do'stlaringiz bilan baham:
1   ...   81   82   83   84   85   86   87   88   ...   103




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