Download presentation
Presentation is loading. Please wait.
Published byBriana Lang Modified over 8 years ago
1
1 Reports
2
2 Objectives Use concatenation in a query Change column headings and formats Add a title to a report Group data in a report Include totals and subtotals in a report Send a report to a file for printing
3
3 Concatenating Columns Concatenation the process of combining two or more character columns into a single expression To concatenate type 2 vertical lines (||) between column names List the sales rep number and name of every sales rep where the name is a concatenation of the FIRST and LAST columns
4
4 RTRIM Function When the first name doesn’t include sufficient characters to fill the width of the column, SQL inserts extra spaces To remove extra spaces, use the right trim function (RTRIM function) Rewrite previous example to use RTRIM function
5
5 Creating a View for the Report Data for a report can come from either a table or a view Often it is simpler to use a view if the report involves data from more than one table
6
6 Selecting Report Data Once the query is built, a file should be created to store the report commands. A / at the end of the file will run the most recently run query
7
7 COLUMN Command Use COLUMN command to change column headings change width of a column change the way entries appear in a column Use CLEAR COLUMNS command to clear any previous column changes Without this command any previous changes made to column headings would still be in place Change the column headings in the report so they are more descriptive of the columns’ content
8
8 FORMAT Command The data in the other columns should be displayed with dollar signs and two decimal places
9
9 TTITLE and BTITLE Command TTITLE command Adds a title to the top of the report BTITLE command Adds a title to the bottom of the report Add a title to the report The title should extend over two lines The fist line is “Customer Financial Report” The second line is Organized by Sales Rep”
10
10 SET LINESIZE Command In order for the table to appear appropriately, adjust the line size by using the SET LINESIZE command Line size determines where the title appears when it is centered across the line SET LINESIZE 70 set the line to a length of 70 characters
11
11 Grouping Data in a Report BREAK Command Identifies a column or collection of columns on which to group data Value of column is displayed only at the beginning of the group In addition, remove the message at the end of the report that indicates the number of rows selected
12
12 Total and Subtotals in a Report A total that appears after each group is called a subtotal To calculate a subtotal, the BREAK command must be used to group the rows Use the COMPUTE command to indicate the computation for the subtotal
13
13 Finishing Touches Include these commands at the top of the report. CLEAR COLUMNS CLEAR COMPUTE CLEAR BREAK
14
14 SPOOL Command Send the report created to the file named PROJ1.OUT
15
15 Report Command Summary
16
16 Summary To concatenate columns in report, separate the column names with two vertical lines (||) Use the RTRIM command to delete any extra spaces that follow the values Use a script to save the commands used to create a report so you can make modifications to the report at a later time
17
17 Summary Reports are based on tables or views that contain the report data Use the COLUMN command to change a column heading Use the HEADING clause to assign a new heading name Type a single vertical line (|) to break a column heading over two lines Use the COUMN command to change the format of column values
18
18 Summary Use the TTITLE or BTITLE command to add a title at the top or bottom of a report, respectively Use the BREAK command to group data in a report Use the BREAK and COMPUTE commands and an appropriate statistical function to calculate data in a report, such as totals and subtotals
19
19 Summary Use the SET PAUSE and SET PAGESZE commands to pause a report after each screen of data, or to change the number of report lines to display Use the SPOOL command to send a report to a file for printing or editing
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.