All Powder Board and Ski

Slides:



Advertisements
Similar presentations
All Powder Board and Ski
Advertisements

1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2007.
All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2007.
Introduction to Structured Query Language (SQL)
IS 4420 Database Fundamentals Chapter 8: Advanced SQL Leon Chen
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Introduction to Structured Query Language (SQL)
SQL Joins.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 11 Introduction to Dynamic SQL and Object Technology.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 4: Queries Jerry Post Copyright © 2007.
1 Chapter 8: Advanced SQL. Chapter 8 2 Processing Multiple Tables – Joins Join – a relational operation that causes two or more tables with a common domain.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
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.
Chapter 6 SQL: Data Manipulation (Advanced Commands) Pearson Education © 2009.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 7: Integrity and Transactions Jerry Post Copyright © 2003.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
All Powder Board and Ski Oracle 9i Workbook Chapter 1 Jerry Post Copyright © 2003.
1 © Prentice Hall, 2002 Chapter 8: Advanced SQL Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
SQL for Data Retrieval. Review Questions of Previous Class Q1. Show the sum of hours worked for project with ID 1200 (use ASSIGNMENT table) – Use “SUM”
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 4: Queries Jerry Post Copyright © 2003.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 10: Distributed Databases Jerry Post Copyright © 2003.
Database Technology Jing Shen.
Subqueries Steve Perry 1.
All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables 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.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
1 All Powder Board and Ski Microsoft Access Workbook Chapter 8: Data Warehouses and Data Mining Jerry Post Copyright © 2003.
Chapter 12 Subqueries and Merge Statements
All Powder Board and Ski Oracle 9i Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 4: Queries Jerry Post Copyright © 2003.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 All Powder Board and Ski SQL Server Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
Chapter 8 1 Lecture Advanced SQL. Chapter 8 2 Processing Multiple Tables–Joins Join – a relational operation that causes two or more tables with.
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.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Relational Database Design
Chapter 12 Subqueries and MERGE Oracle 10g: SQL
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Introduction to SQL 2016 Temporal Tables
© 2016, Mike Murach & Associates, Inc.
Chapter 2: Database Design All Powder Board and Ski
All Powder Board and Ski
More on Oracle Scripts CSC 240 (Blum).
SQL: Advanced Options, Updates and Views Lecturer: Dr Pavle Mogin
CHAPTER 7: ADVANCED SQL.
Insert, Update, Delete Manipulating Data.
Chapter 10 Oracle9i Developer: PL/SQL Programming
Introduction To Structured Query Language (SQL)
Yong Choi School of Business CSU, Bakersfield
Introduction To Structured Query Language (SQL)
Chapter 8 Advanced SQL.
Topic 12 Lesson 2 – Retrieving Data with Queries
Manipulating Data Lesson 3.
Triggers 7/11/2019 See scm-intranet.
Presentation transcript:

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

Primary Tables

Find Best Customers: 1 Total sales by customer.

Average Customer Sales

Best Customers Subquery

INNER JOIN: Sales and Rentals

Left Join: Sales + Rental Left Join Sale+Customer to Rental Sales without rentals

Inner Join: Same Customer and Day

NOT IN Not In subquery to list those who did NOT rent

Model Quantity On Hand

Categories

Inequality Join Inequality (theta) joins assign the proper category name

Sales Categories Find the number of models in each sales category

UNION Query List customers who bought items in January or in March. Note: it could be done with simple conditions, but it is good practice for UNION.

CREATE TABLE Query CREATE TABLE Contacts ( ContactID INTEGER, ManufacturerID INTEGER, LastName NVARCHAR2(25), FirstName NVARCHAR2(25), Phone NVARCHAR2 (15), Email NVARCHAR2 (120), CONSTRAINT pk_Contacts PRIMARY KEY (ContactID), CONSTRAINT fk_ContactsManufacturer FOREIGN KEY (ManufacturerID) REFERENCES Manufacturer(ManufacturerID) ) ;

Create a Temporary Table CREATE TABLE MyTemp ( ID INTEGER, LName NVARCHAR2(25), FName NVARCHAR2(25), CONSTRAINT pk_MyTemp PRIMARY KEY (ID) );

INSERT INTO (One Row) INSERT INTO Customer (CstomerID, LastName, FirstName, City, Gender) VALUES (4000, 'Jones', 'Jack', 'Nowhere', 'Male'); Lab 7 shows how to create sequences so CustomerID is generated automatically.

INSERT INTO (Copy Rows) INSERT INTO MyTemp (ID, LName, FName) SELECT CustomerID, LastName, FirstName FROM Customer WHERE City='Sacramento' ;

UPDATE Board Cost Test query to see new values. Delete it before running second query Query to change data in the Cost column

DELETE Rows First write a SELECT query to see the rows Second change the SELECT row to DELETE Execute the Commit; statement to permanently save changes

DROP TABLE DROP TABLE MyTemp;

Query Parameters SELECT Category, Sum(RentFee) AS SumOfRentFee FROM Rental INNER JOIN RentItem INNER JOIN Inventory INNER JOIN ItemModel ON Inventory.ModelID=ItemModel.ModelID ON RentItem.SKU=Inventory.SKU ON Rental.RentID=RentItem.RentID WHERE RentDate Between ’01-Jan-2004’ And ’31-Mar-2004’ GROUP BY Category; Need to replace fixed dates with parameters that can be entered by a manager

Query Parameters: Package CREATE PACKAGE pckCategoryFees AS TYPE typeCategoryFees IS RECORD ( Category NVARCHAR2(15), SumOfRentFees NUMBER(8,2) ); TYPE typeCursorFees IS REF CURSOR RETURN typeCategoryFees; PROCEDURE GetCategoryFees ( dateStart IN DATE, dateEnd IN DATE, cvFees IN OUT typeCursorFees END; /

Package Body CREATE PACKAGE BODY pckCategoryFees AS PROCEDURE GetCategoryFees ( dateStart IN DATE, dateEnd IN DATE, cvFees IN OUT typeCursorFees ) IS BEGIN OPEN cvFees FOR SELECT Category, Sum(RentFee) AS SumOfRentFee FROM Rental INNER JOIN RentItem INNER JOIN Inventory INNER JOIN ItemModel ON Inventory.ModelID=ItemModel.ModelID ON RentItem.SKU=Inventory.SKU ON Rental.RentID=RentItem.RentID WHERE RentDate Between dateStart And dateEnd GROUP BY Category; END;

Query Parameters Parameters: dateStart and dateEnd