A Guide to SQL, Seventh Edition

Slides:



Advertisements
Similar presentations
Copyright © 2007, Oracle. All rights reserved Using Single-Row Functions to Customize Output Modified: October 21, 2014.
Advertisements

Excel Tutorial 1 Getting Started with Excel
7 Copyright © Oracle Corporation, All rights reserved. Producing Readable Output with i SQL*Plus.
Concepts of Database Management Sixth Edition
Chapter 11 Group Functions
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
Introduction to Oracle9i: SQL1 Selected Single-Row Functions.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Mary K. Olson PS Reporting Instance – Query Tool 101.
Concepts of Database Management Sixth Edition
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
Microsoft Access 2010 Chapter 7 Using SQL.
1 Excel Lesson 3 Organizing the Worksheet Microsoft Office 2010 Introductory Pasewark & Pasewark.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Lesson 5: Using Tables.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 2 Basic SQL SELECT Statements
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Chapter 3 Single-Table Queries
1 Copyright © 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Concepts of Database Management Seventh Edition
XP Agenda Video Last Class Excel Tutorial 5: Working with Excel Lists Agenda for Next Class 1 New Perspectives on Microsoft Office Excel 2003 Tutorial.
XP 1 Excel Tables Purpose of tables – Process data in a group – Used to facilitate calculations – Used to enhance readability of output Types of tables.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Concepts of Database Management Seventh Edition
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Chapter 1 Creating a Dreamweaver Web Page and Local Site
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
1 Reports. 2 Objectives  Use concatenation in a query  Change column headings and formats  Add a title to a report  Group data in a report  Include.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
Oracle Command Spool Spool C:\temp\Lab9.lst Select Hotel_no, room_no, type, price From Room Order by Hotel_no; Spool Off.
A Guide to SQL, Seventh Edition. Objectives Understand how to use functions in queries Use the UPPER and LOWER functions with character data Use the ROUND.
XP. Objectives Sort data and filter data Summarize an Excel table Insert subtotals into a range of data Outline buttons to show or hide details Create.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Chapter 14 Formatting Readable Output. Chapter Objectives  Add a column heading with a line break to a report  Format the appearance of numeric data.
External Executable Tools The Master's Touch David L. Blankenship.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
Working with Columns, Characters, and Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Apply the concatenation.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Chapter 21: Report writing1 Chapter Twenty One Producing Readable Output Objectives: Writing reports Page set up Page layout Queries with input.
Writing Basic SQL SELECT Statements Lecture
A Guide to SQL, Sixth Edition 1 Chapter 7 Reports.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Microsoft Excel Illustrated Introductory Workbooks and Preparing them for the Web Managing.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
3 A Guide to MySQL.
Retrieving Data Using the SQL SELECT Statement
A Guide to SQL, Seventh Edition
Open Source Server Side Scripting MySQL Functions
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
Chapter Twenty Producing Readable Output
Using SQL*Plus.
Guide To UNIX Using Linux Third Edition
Writing Basic SQL SELECT Statements
ORACLE.
CHAPTER 17 The Report Writer Module
From and Report.
Lecture 5 SQL FUNCTIONS.
Producing Readable Output with iSQL*Plus
Microsoft Office Illustrated Introductory, Windows XP Edition
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

A Guide to SQL, Seventh Edition

Objectives Understand how to use functions in queries Use the UPPER and LOWER functions with character data Use the ROUND and FLOOR functions with numeric data Add a specific number of months or days to a date Calculate the number of days between two dates Use concatenation in a query A Guide to SQL, Seventh Edition

Objectives Create a view for a report Create a query for a report Change column headings and formats in a report Add a title to a report Group data in a report Include totals and subtotals in a report Send a report to a file that can be printed A Guide to SQL, Seventh Edition

Using Functions Using GROUP BY function with aggregate functions will provide sums for each record in a group Other functions are available that work with single records Functions vary among applications A Guide to SQL, Seventh Edition

Character Functions Several functions work with character data UPPER function for changing a value to uppercase letters LOWER function changes values to lowercase letters A Guide to SQL, Seventh Edition

Number Functions Number functions affect numeric data ROUND function rounds values to a specified number of places Has two arguments: the value to be rounded and the number of decimal places FLOOR function removes values to the right of the decimal point A Guide to SQL, Seventh Edition

Working With Dates Functions and calculations are used for manipulating dates ADD_MONTHS function allows for adding a specific number of months to a date Has two arguments: date to add to and the number of months to add In Access, use DATEADD function In MySQL, use ADDDATE function A Guide to SQL, Seventh Edition

Working With Dates No function is needed to add a specific number of days to a date In Access, use the DATEADD function with the letter “d” as the time interval In MySQL, use the ADDDATE function with the DAY interval A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Working With Dates Use SYSDATE to obtain today’s date A Guide to SQL, Seventh Edition

Concatenating Columns Concatenation is the process of combining two or more character columns into a single expression In Access, use the & symbol Select REP_NUM, FIRST_NAME&LAST_NAME FROM REP; In MySQL, use the CONCAT function Select REP_NUM,CONCAT(FIRST_NAME, LAST_NAME) FROM REP; A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Creating and Using Scripts Saving commands in a script file eliminates retyping Creating views Entering report formatting command When creating a report you typically create a view and three files Script to create the view Script to format the report Report output A Guide to SQL, Seventh Edition

Naming Conventions Save script to create the view with the view name SLSR_REPORT as SLSR_REPORT_VIEW.sql Save the script to format the view SLSR_REPORT as SLSR_REPORT_FORMAT.sql Save the file with report output SLSR_REPORT as SLSR_REPORT_OUTPUT.sql A Guide to SQL, Seventh Edition

Running Script Files Example: @SLSR_REPORT To run a script file, type @ followed by the file name Example: @SLSR_REPORT Script files can be saved to any storage location Scripts allow you to develop your report in stages A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Creating the Data for the Report To produce a report, run a SELECT command to create data to use in report In the following example, rows in output are wider than the screen Each row is displayed on two lines A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Changing Column Headings Column headings can be changed to improve readability Type the COLUMN command followed by the name of the column to change Follow with the HEADING clause and new heading To break a heading on two lines, use single vertical line (|) A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Changing Column Formats COLUMN command and FORMAT clause work together A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Adding a Title to a Report TTITLE command will place a title at the top BTITLE command will place a title at the bottom Desired title is placed within single quotation marks To format title with line breaks, use single vertical line (|) A Guide to SQL, Seventh Edition

Adding a Title to a Report Adjust line size with SET LINESIZE command Line size is the maximum number of characters each line can contain Adjust the number of lines per page with SET PAGESIZE command A Guide to SQL, Seventh Edition

Grouping Data in a Report Group data in a report by using BREAK command BREAK command identifies a column on which to group data Value in the column is displayed only at the beginning of the group It is possible to specify the number of blank lines following a group A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Including Totals and Subtotals in a Report Subtotal is a total that appears after each group To calculate a subtotal, include BREAK command to group the rows COMPUTE command indicates computation for subtotal Statistical functions are used to calculate the values A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Sending the Report to a File SPOOL command is used in Oracle to create a report output file This file has many uses: Printing Editing Importing into a document Other options A Guide to SQL, Seventh Edition

The SPOOL Command Sends output of subsequent commands to designated file Final command of SPOOL OFF turns off spooling and stops further output to designated file Include path name to save output file to a specific drive or folder A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

A Guide to SQL, Seventh Edition

Summary Use of functions Perform calculations with dates UPPER and LOWER ROUND and FLOOR Perform calculations with dates Concatenate columns Commands to create and format reports A Guide to SQL, Seventh Edition