Yong Choi School of Business CSU, Bakersfield

Slides:



Advertisements
Similar presentations
Advanced SQL Topics Edward Wu.
Advertisements

Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
Structured Query Language (SQL)
UNITED NATIONS Shipment Details Report – January 2006.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Exit a Customer Chapter 8. Exit a Customer 8-2 Objectives Perform exit summary process consisting of the following steps: Review service records Close.
Create an Application Title 1A - Adult Chapter 3.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 5 second questions
Year 6 mental test 10 second questions
Around the World AdditionSubtraction MultiplicationDivision AdditionSubtraction MultiplicationDivision.
Solve Multi-step Equations
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
1 CIFTlab1.2 Software for Clinical Diagnostic Laboratories 1.
ABC Technology Project
EU market situation for eggs and poultry Management Committee 20 October 2011.
EU Market Situation for Eggs and Poultry Management Committee 21 June 2012.
MySQL Access Privilege System
Microsoft Office Illustrated Fundamentals Unit K: Working with Data.
Vanderbilt Business Objects Users Group 1 Reporting Techniques & Formatting Beginning & Advanced.
2 |SharePoint Saturday New York City
VOORBLAD.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
Adding Up In Chunks.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Subtraction: Adding UP
Januar MDMDFSSMDMDFSSS
Analyzing Genes and Genomes
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
Energy Generation in Mitochondria and Chlorplasts
Concepts of Database Management, 4th Edition, Pratt & Adamski
SQL (Standard Query Language) Yong Choi School of Business CSU, Bakersfield.
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Yong Choi School of Business CSU, Bakersfield
Presentation transcript:

Yong Choi School of Business CSU, Bakersfield SQL Assignment Yong Choi School of Business CSU, Bakersfield

Study Objectives Understand the basic commands and functions of SQL Learn how SQL is used for data manipulation (to add, modify, delete, and retrieve data) Learn how to use SQL to query a database to extract useful information Learn how SQL is used for data administration (to create tables, indexes, and views) Practice SQL

Ideal Database Language Requirements Create database and table structures. SQL has a data definition component that gives us the ability to meet this requirement. Manage the data component of the database. SQL gives us a set of commands to add, update, and delete data within the database tables. Provide detailed data query capability. "Standard" SQL uses a set of approximately thirty commands that allow us to retrieve data and to convert the raw data into useful information.

Introduction to SQL Standard Query Language (SQL) is the relational model’s standard language. The original version of SQL was developed at IBM's San Jose Research Laboratory. This language, originally called Sequel. The Sequel language has evolved since then, and its name has changed to SQL (Structured Query Language). In 1986, the American National Standards Institute (ANSI) published an SQL standard. In 1992, work was completed on a significantly revised version of the SQL standard (SQL-92).

Introduction to SQL (con’t) SQL is relatively easy to learn SQL commands set has a basic vocabulary of less than 100 words. SQL is a nonprocedural language. So, it is much easier to use. Its user merely commands what is to be done without having to worry about how it's to be done. Procedural language: COBOL, C, or Pascal.

More about SQL Three basic data functions by SQL, and their basic SQL commands: Data definition through the use of CREATE Data manipulation through INSERT, UPDATE, and DELETE Data querying through the use of SELECT AND MANY OTHERS, which is the basis for all SQL queries. We will try this first since we just completed all Access queries.

Basic Structure of SQL Queries SQL relation is not a set of tuples because a set does not allow two identical members; rather it is a multi-set (a bag) of tuples. A SQL query has the form: SELECT <attribute list> FROM <table list> WHERE <condition> GROUP BY < grouping attribute(s)> HAVING <group condition> ORDER BY <attribute list>

The SELECT and FROM Statement The SELECT statement is used to select data from a table. The tabular result is stored in a result table (called the result set). The FROM statement is used to select tables. Syntax: SELECT column_name(s) FROM table_name To select all columns from a table, use a * symbol instead of column names:  SELECT * FROM table_name

The WHERE Statement To conditionally select data from a table, a WHERE clause can be added to the SELECT statement. Syntax: SELECT column FROM table WHERE column operator value

Typical Data Types INTEGER: Numbers without a decimal point SMALLINT: Uses less space than INTEGER DECIMAL(p,q): P number of digits; q number of decimal places CHAR(n): Character string n places long DATE: Dates in DD-MON-YYYY or MM/DD/YYYY

SQL Assignment Assignment questions start from the next slide. Answer Table is given as a hint for each question.

SQL Assignment Question 2: Save as Assignment Question 2 List the number, name, and balance of all customers. Assignment Question 3: Save as Assignment Question 3 List the complete Part table.

Assignment Question 2

Assignment Question 3

SQL – WHERE clause Assignment Question 4: Save as Assignment Question 4 List the name of every customers with $10,000 credit limit. Assignment Question 5: Save as Assignment Question 5 Find the name of customer 148.

SQL Query with Where Condition Assignment Question 4 SQL Query with Where Condition

SQL Query to Find Customer 148 Assignment Question 5 SQL Query to Find Customer 148

SQL Comparison Operators FOR WHERE clause NOT Warehouse =‘3’ LIKE: LIKE ‘a*’, LIKE ‘*s’, Like ‘*Oxford*’ (NOT) BETWEEN 45000 AND 78000 (NOT) IN (123, 345)

SQL Assignment Question 6: Save as Assignment Question 6 Find the customer name for every customer located in the city of Grove Assignment Question 7: Save as Assignment Question 7 List the number, name, credit limit, and balance for customers with credit limits that exceed their balances.

Assignment Question 6

Assignment Question 7

SQL – Compound Conditions Assignment Question 8: Save as Assignment Question 8 List the description of all parts that are located in warehouse 3 and for which there are more than 20 units on hand. Assignment Question 9: Save as Assignment Question 9 List the descriptions of all parts that are located in warehouse 3 or for which there are more than 20 units on hand.

SQL Query with Compound Condition using ‘AND’ Assignment Question 8 SQL Query with Compound Condition using ‘AND’

Assignment Question 9 SQL Query using ‘OR’

SQL Assignment Question 10: Save as Assignment Question 10 List the description of all parts that are not in warehouse 3. Assignment Question 11: Save as Assignment Question 11 List the number, name, and balance of all customers with balances greater than or equal to $1,000 and less than or equal to $5,000.

Assignment Question 10 SQL Query using ‘NOT’

Query with ‘BETWEEN’ Operator Assignment Question 11 Query with ‘BETWEEN’ Operator

SQL – Computed Field Computed field can involve: addition(+), subtraction(-), Multiplication(*), or division (/) Assignment Question 12: Save as Assignment Question 12 List the number, name and available credit for all customers. Assignment Question 13: Save as Assignment Question 13 List the number, name, and available credit for all customers with credit limits that exceed their balances.

SQL Query with Computed Field Assignment Question 12 SQL Query with Computed Field

SQL Query with Computed Assignment Question 13 SQL Query with Computed Field and Condition

SQL – LIKE and IN Assignment Question 14: Save as Assignment Question 14 List the number, name, and complete address of every customer located on a street that contain the letters “Oxford.” Customer names begin with B Customer names end with E Assignment Question 15: Save as Assignment Question 15 List the number, name, and credit limit for every customer with a credit of $7,500, $10,000, or $15,000.

SQL Query with ‘LIKE’ Operator Assignment Question 14 SQL Query with ‘LIKE’ Operator

SQL Query with ‘IN’ Operator Assignment Question 15 SQL Query with ‘IN’ Operator

SQL Default value of ORDER BY: ascending Assignment Question 16: Save as Assignment Question 16 List the number, name, and credit limit of all customers. Sort the customers by name in ascending order . Assignment Question 17: Save as Assignment Question 17 List the number, name, and credit limit of all customers. Sort the customers by name (minor) in ascending order within credit limit (major) in descending order. What about this case? customer name (minor) and credit limit (major)

Assignment Question 16 SQL Query to Sort Data

SQL Query to Sort on Multiple Fields Assignment Question 17 SQL Query to Sort on Multiple Fields