Example 2 SELECT Customernum, CustomerName, Balance FROM Customer;

Slides:



Advertisements
Similar presentations
Multiple Table Queries
Advertisements

Concepts of Database Management Seventh Edition
Yong Choi School of Business CSU, Bakersfield
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.
Example 18 SELECT count(*) FROM Part WHERE Class="HW";
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 Basics Based on the relational algebra we just learned. Nonprocedural language – what to be done not how Simple, powerful language Used for both data.
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 (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 1 Chapter One Introduction to Premiere Products, Henry Books, and Alexamara Marina Group.
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.
A Guide to MySQL. 2 Objectives Introduce Premiere Products, a company whose database is used as the basis for many of the examples throughout the text.
Getting to Know SQL. © Jim Hope 2002 All Rights Reserved Data Manipulation SELECT statement INSERT INTO statement UPDATE statement DELETE statement TRANSFORM.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management Seventh Edition
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.
Database & Data Warehouse Assignments BCIS 4660 – Dr. Nick Evangelopoulos Spring 2012.
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 MySQL.
Structured Query Language
A Guide to SQL, Eighth Edition
Database, tables and normal forms
A Guide to SQL, Eighth Edition
Concepts of Database Management Seventh Edition
Concepts of Database Management Eighth Edition
Normalization – Part II
RELATIONAL DATABASES AND XML
Enterprise Conceptual Relational
Yong Choi School of Business CSU, Bakersfield
Yong Choi School of Business CSU, Bakersfield
Schema Template Employee Office EmployeeOffice EmployeeID OfficeID
Yong Choi School of Business CSU, Bakersfield
ITEC 3220M Using and Designing Database Systems
COP 2700 – Data Structures - SQL
ER Diagram Master How to use this template
Chapter 14 Normalization Pearson Education © 2009.
Presentation transcript:

Example 2 SELECT Customernum, CustomerName, Balance FROM Customer;

Example 3 SELECT * FROM Part;

Example 4 SELECT Customername FROM Customer WHERE CreditLimit=10000;

Example 5 SELECT Customer.CustomerNum FROM Customer WHERE Customer.CustomerNum='148';

Example 6 SELECT Customername FROM Customer WHERE City = ‘Grove';

Example 7 SELECT CustomerName, CustomerName, CreditLimit, Balance FROM Customer WHERE CreditLimit>Balance;

Example 8 SELECT Description FROM Part WHERE Warehouse=‘3’ AND OnHand>20;

Example 9 SELECT Description FROM Part WHERE Warehouse=‘3’ OR OnHand>20;

Example 10 SELECT Description FROM Part WHERE NOT Warehouse=‘3’;

Example 11 SELECT CustomerNum, CustomerName, Balance FROM Customer WHERE Balance BETWEEN 1000 AND 5000;

Example 12 SELECT CustomerNum, CustomerName, CreditLimit-Balance AS AvailableCredit FROM Customer;

Example 13 SELECT CustomerNum, CustomerName, CreditLimit-Balance AS AvailableCredit FROM Customer WHERE CreditLimit > Balance;

Example 14 SELECT CustomerNum, CustomerName, Street, City, State, Zip FROM Customer WHERE Street LIKE ‘*Oxford*’;

Example 15 SELECT CustomerNum, CustomerName, CreditLimit FROM Customer WHERE CreditLimit IN (7500, 10000, 15000);

Example 16 SELECT CustomerNum, CustomerName, CreditLimit FROM Customer ORDER BY CustomerName;

Example 17 SELECT CustomerNum, CustomerName, CreditLimit FROM Customer ORDER BY CreditLimit DESC, CustomerName;

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 ORDER BY RepNum;

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

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

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

Example 25 SELECT CustomerNum, CustomerName, Rep.RepNum, LastName, FirstName FROM Customer, Rep WHERE Customer.RepNum=Rep.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 CREATE TABLE Employee; INSERT INTO Employee VALUES ('987654321', 'Choi', 'Yong', '9001 Stockdale', 'Bakersfield', 'CA', '123456789');