1 All Powder Board and Ski Oracle 9i Workbook Chapter 4: Queries Jerry Post Copyright © 2003.

Slides:



Advertisements
Similar presentations
All Powder Board and Ski
Advertisements

1 All Powder Board and Ski Microsoft Access Workbook Chapter 9: Data Warehouses and Data Mining Jerry Post Copyright © 2007.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2007.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007.
CC SQL Utilities.
Microsoft Excel Presented by ShoWorks Fair Software and Online Entries
1 All Powder Board and Ski SQL Server Workbook Chapter 4: Queries Jerry Post Copyright © 2003.
Exploring Microsoft Excel 2002 Chapter 7 Chapter 7 List and Data Management: Converting Data to Information By Robert T. Grauer Maryann Barber Exploring.
Microsoft Excel Working with Excel Lists, Subtotals and Pivot Tables.
5 Chapter 5 Structured Query Language (SQL2) Revision.
Databases Lab 5 Further Select Statements. Functions in SQL There are many types of functions provided. The ones that are used most are: –Date and Time.
Chapter 7 Data Management. Agenda Database concept Import data Input and edit data Sort data Function Filter data Create range name Calculate subtotal.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Office 2010 Vol. 1 PowerPoint Lecture to Accompany Skills.
Concepts of Database Management Sixth Edition
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
SQL 資料庫查詢語言 取材自 EIS, 3 rd edition By Dunn et al..
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 4: Queries Jerry Post Copyright © 2007.
Chapter 5 Advanced Querying
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 7: Integrity and Transactions Jerry Post Copyright © 2003.
1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 10: Distributed Databases Jerry Post Copyright © 2003.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
Concepts of Database Management Seventh Edition
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
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.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 10: Distributed Databases Jerry Post Copyright © 2003.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
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.
1 Chapter 3: Customize, Analyze, and Summarize Query Data Exploring Microsoft Office Access 2007.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms, Reports, and Applications Jerry Post Copyright © 2003.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 8: Data Warehouses and Data Mining Jerry Post Copyright © 2003.
All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2003.
1 Copyright © 2010 Jerry Post & M. E. Kabay. All rights reserved. Queries: Part 2 of 2 IS240 – DBMS Lecture # 7 – M. E. Kabay, PhD, CISSP-ISSMP.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 8: Data Warehouses and Data Mining Jerry Post Copyright © 2003.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 4: Queries Jerry Post Copyright © 2003.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
DAY 21: ACCESS CHAPTER 6 & 7 Tazin Afrin October 31,
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
A Guide to SQL, Sixth Edition 1 Chapter 7 Reports.
1 All Powder Board and Ski SQL Server Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
ACIS Introduction to Data Analytics & Business Intelligence Business Intelligence Logical Functions Part 2.
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.
1 ORACLE I 3 – SQL 1 Salim Phone: YM: talim_bansal.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
IFS180 Intro. to Data Management Chapter 10 - Unions.
McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10: Distributed Databases and the Internet All Powder.
McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9: Database Administration All Powder Board and Ski.
Chapter 6: Forms, Reports and Applications All Powder Board and Ski
A Guide to SQL, Seventh Edition
M. E. Kabay, PhD, CISSP-ISSMP V:
Chapter 1 Introduction.
Chapter 2: Database Design All Powder Board and Ski
All Powder Board and Ski
All Powder Board and Ski
Structured Query Language (SQL) William Klingelsmith
Chapter 1 Introduction.
Chapter 1 Introduction.
Chapter 1 Introduction.
Presentation transcript:

1 All Powder Board and Ski Oracle 9i Workbook Chapter 4: Queries Jerry Post Copyright © 2003

2 Primary Tables

3 File/Get External Data/Import (1)Copy BuildAllPowder folder to machine running SQL Plus (2)Drop or rename any conflicting tables (1)By hand (2)In SQL Plus, run the file DropAllPowserTablesOracle.sql (3)Edit BuildAllPowderOracle.sql in Wordpad and set the directory for the CSV files (4)Start SQL Plus (not the worksheet) create or replace directory csv_dir as 'd:\students\BuildAllPowder\AllPowderSampleDataCSV';

4 All Powder Tables after Import

5 Starting a Query: SQL Worksheet SQL statement Results Database connection Execute query Prior commands

6 Sample Query Display snowboards with a list price under $300 and max weight over 150 pounds. SQL Results

7 Formatting Columns Set width Format currency

8 More Complex Query Ski for jumping. Composite material. Red or Yellow main color. Yellow skis must be under $300. Red skis must be under $400 Three main conditions WHERE Category=‘Ski’ AND ItemMaterial=‘Composite’ AND Style=‘Jump’

9 Color Options Yellow and price conditions All 5 conditions must hold, so only one row matches

10 Multiple Conditions ( (Color=‘Yellow’ AND ListPrice<300) OR (Color=‘Red’ AND ListPrice<400) )

11 JOIN Query: Sales Sales in May Cash payment

12 JOIN Tables: Sale + Customer Join condition Additional columns

13 JOIN: SQL COLUMN PaymentMethod Format A15; COLUMN LastName Format A15; COLUMN FirstNAme Format A15; SELECT SaleID, SaleDate, Sale.CustomerID, LastName, FirstName, PaymentMethod FROM Sale INNER JOIN Customer ON Sale.CustomerID = Customer.CustomerID WHERE SaleDate Between '01-May-2004' AND '31-May-2004' AND PaymentMethod='Cash' ;

14 Building a more complex query Which customers bought Atomic skis in January or February? What do you want to see?Customer names, SaleDate What do you know?Manufacturer name, SaleDate range, Category is Ski What tables are involved? How are they joined? Customer … Sale … ItemModel, Manufacturer SELECTLastName, FirstName, SaleDate FROM Customer, …, Sale, …, ItemModel, Manufacturer JOIN WHERE Manufacturer.Name=‘Atomic”’ AND Sale.SaleDate BETWEEN ‘01-Jan-2004’ AND ‘29-Feb-2004’ AND ItemModel.Category = ‘Ski’

15 Join: Many Tables

16 SQL: Many Table Joins COLUMN LastName Format A15; COLUMN FirstName Format A15; COLUMN Category Format A15; SELECT LastName, FirstName, Category, Name, SaleDate FROM Manufacturer INNER JOIN ItemModel INNER JOIN Inventory INNER JOIN SaleItem INNER JOIN Sale INNER JOIN Customer ON Sale.CustomerID = Customer.CustomerID ON SaleItem.SaleID = Sale.SaleID ON Inventory.SKU = SaleItem.SKU ON ItemModel.ModelID = Inventory.ModelID ON Manufacturer.ManufacturerID = ItemModel.ManufacturerID WHERE Category = 'Ski' AND Name='Atomic' AND SaleDate BETWEEN '01-Jan-2004' AND '29-Feb-2004' ;

17 Older Join Method List tables separated by commas Place join condition in the WHERE clause

18 Calculations Calculated column

19 Common Functions LowerTo lower case LengthLength/number of characters SubstrGet substring TrimRemove leading and trailing spaces UpperTo upper case SYSDATECurrent date ADD_MONTHSAdd days, months, years to a date MONTHS_BETWEENSubtract two dates TO_CHARHighly detailed formatting TO_DATEFormat dates SYSDATECurrent date and time AbsAbsolute value CosCosine, all common trig functions FloorInteger, drop decimal values RoundRound-off

20 Format Dates: TO_CHAR

21 DateAdd and DateDiff SaleDate + one month SaleDate + 30 days

22 Query: Sum Sum function

23 SQL: Sum SELECT Sum(Sale.SalesTax) AS SumOfSalesTax FROM Sale WHERE Sale.ShipState=‘CA’

24 Query: Group By Group By produces subtotals for all values in the specified column

25 SQL: Group By SELECT ShipState, Sum(SalesTax) AS SumOfSalesTax FROM Sale GROUP BY ShipState;

26 Total Sales Value in Colorado Multiply on each row and sum across rows

27 CREATE VIEW—Save a Query CREATE VIEW ColoradoSales AS SELECT Sum(QuantitySold*SalePrice) AS SaleTotal FROM Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleID WHERE ShipState=’CO’