Example 18 SELECT count(*) FROM Part WHERE Class="HW";

Slides:



Advertisements
Similar presentations
Database Design DB Chapter 5 J.G. Zheng June 29th 2005.
Advertisements

Database Design J.G. Zheng May 19 th Overview Entity Relationship Modeling Data modeling using Entity Relationship Diagram (ERD) Transforming.
Multiple Table Queries
Concepts of Database Management Seventh Edition
Tonight’s Lecture chapter 3. A Guide to MySQL2 Using MySQL Reference Manual to Get Help Can access online
Concepts of Database Management Seventh Edition Chapter 6 Database Design : ERD Model.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Adamson & Venerable Chapter 2 & working out a Homework 5/6 Solution Transforming Relational Databases into Dimensional Diagrams Spring 2012.
Structured Query Language STAT 598 W Lecture 27. Outline  Introduction to SQL & MySQL  Single table Queries –Using computed columns –Using special operators:
DBS201: Merging 3NF Tables Lecture 7.
Chapter 8 Embedded SQL.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management, 4th Edition, Pratt & Adamski
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Concepts of Database Management Sixth Edition
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
SQL (Standard Query Language) Yong Choi School of Business CSU, Bakersfield.
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Part ( PartNum, Description, OnHand, Class, Warehouse, Price,
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
Concepts of Database Management Sixth Edition Chapter 5 Database Design 1: Normalization.
1 A Guide to MySQL 2 Database Design Fundamentals.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
1 A Guide to MySQL 2 Database Design Fundamentals.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Seventh Edition
Database & Data Warehouse Assignments BCIS 4660 – Dr. Nick Evangelopoulos Spring 2012.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
1 Access: Create a Table from a Query, Eg 31 SELECT * INTO SmallCust3 FROM Customer WHERE CreditLimit
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
DO NOT COPY --CONFIDENTIAL Homework 5 Partial Key Star Diagrams & Data Warehouse Design BCIS 4660 Dr. Nick Evangelopoulos Spring 2012.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
A Guide to SQL, Sixth Edition 1 Chapter 5 Updating Data.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 5 Part II.
Normalization ACSC 425 Database Management Systems.
2/170 ( Premiere Products ). Invoice (InvoiceNum, CustomerNum, LastName, FirstName, Street, City, State, Zip, Date, (PartNum, Description, Price, NumShipped.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 2.
1 First Normal Form (1NF) Unnormalized table : Contains a repeating group –Eg: from multi-valued attributes –Eg: from many-many relationship Table in 1NF:
Database & Data Warehouse Assignments
A Guide to SQL, Seventh Edition
A Guide to SQL, Eighth Edition
Database, tables and normal forms
A Guide to SQL, Seventh Edition
A Guide to SQL, Eighth Edition

Concepts of Database Management Seventh Edition
Concepts of Database Management Eighth Edition
Insert, Update, Delete Manipulating Data.
Normalization – Part II
RELATIONAL DATABASES AND XML
Example 2 SELECT Customernum, CustomerName, Balance FROM Customer;
Enterprise Conceptual Relational
Yong Choi School of Business CSU, Bakersfield
Yong Choi School of Business CSU, Bakersfield
Yong Choi School of Business CSU, Bakersfield
ITEC 3220M Using and Designing Database Systems
COP 2700 – Data Structures - SQL
Chapter 14 Normalization Pearson Education © 2009.
User Views and merging relations & Journaling
Presentation transcript:

Example 18 SELECT count(*) FROM Part WHERE Class="HW";

Example 19 SELECT count(*), Sum(Balance) FROM Customer;

Example 20 SELECT count(*) AS CustomerCount, Sum(Balance) AS BalanceTotal FROM Customer;

Example 21 SELECT OrderNum FROM OrderLine WHERE PartNum IN (SELECT PartNum FROM Part WHERE Warehouse='3');

Example 22 SELECT RepNum, Count(*) AS NumOfCustomer, Avg(Balance) AS AvgBalance FROM Customer GROUP BY RepNum

Example 23 SELECT RepNum, count(*) AS NumCustomer, Avg(Balance) AS AverageBalance FROM Customer GROUP BY RepNum HAVING Count(*)<4;

Example 23-1 SELECT RepNum, count(*) AS NumCustomer, Avg(Balance) AS AverageBalance FROM Customer WHERE CreditLimit<10000 GROUP BY RepNum HAVING Count(*)<3;

Example 24 SELECT CustomerNum, CustomerName, Rep.RepNum, LastName, FirstName FROM Customer, Rep WHERE Rep.RepNum=Customer.RepNum;

Example 25 SELECT CustomerNum, CustomerName, Rep.RepNum, LastName, FirstName FROM Customer, Rep WHERE Rep.RepNum=Customer.RepNum AND CreditLimit=10000;

Example 26 SELECT Orders.OrderNum, Orderdate, Customer.CustomerNum, CustomerName, Part.PartNum, Description, NumOrdered, QuotedPrice FROM Orders, Customer, OrderLine, Part WHERE Customer.CustomerNum=Orders.CustomerNum AND Orders.OrderNum=OrderLine.OrderNum AND OrderLine.PartNum=Part.PartNum;

Example 27 SELECT CustomerNum, CustomerName FROM Customer WHERE RepNum='35' UNION SELECT Customer.CustomerNum, CustomerName FROM Customer, Orders WHERE Customer.CustomerNum=Orders.CustomerNum;

Example 28 UPDATE Customer SET Street = '1445 Rivard' WHERE CustomerNum='524';

Example 29 INSERT INTO Rep VALUES ('16', 'Rands', 'Shron', '826 Raymond', 'Altonville', 'FL', '32543', 0, 0.05);

Example 30 DELETE * FROM OrderLine WHERE PartNum='BV06';

Example 31 SELECT * INTO SmallCust FROM Customer WHERE CreditLimit<=7500;

Example 32 INSERT INTO Employee VALUES (' ', 'Choi', 'Yong', '9001 Stockdale', 'Bakersfield', 'CA', ' ');