Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSIS 115 Database Design and Applications for Business

Similar presentations


Presentation on theme: "CSIS 115 Database Design and Applications for Business"— Presentation transcript:

1 CSIS 115 Database Design and Applications for Business
Dr. Meg Fryling “Dr. Meg” Fall 2012 @SienaDrMeg #csis115 © 2012 Meg Fryling

2 Agenda Normalization Review Chapter 2: Advanced SQL
Next Quiz (Mon, 12/3) Take online via Blackboard before 11:59pm Must complete quiz once it is started Topics: Normalization & Other DB Issues Homework 4 Due Wednesday, November 28th by 11:59pm

3 Rest of Semester Agenda
11/28: Advanced SQL 12/3: Advanced SQL Online quiz on normalization & other DB issues 12/5: Forms and Reports Workshop Online quiz on SQL 12/10: Review Final Exam Thursday, December 13th, 8:30-10:30am RB350 (Open Lab)

4 Student Evaluations Available starting tomorrow
Have until midnight on December 11th (Reading Day) to complete If I get at least a 95% response rate, I will drop the lowest quiz grade for everyone!

5 Normalization Review Dogs In-Class Activity Homework 4

6 The SQL Keyword GROUP BY
SELECT Department, Buyer, COUNT(*) AS Dept_Buyer_SKU_Count FROM SKU_DATA GROUP BY Department, Buyer; What is this query going to return? KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

7 The SQL Keyword GROUP BY
SELECT Department, COUNT(*) AS Dept_SKU_Count FROM SKU_DATA WHERE SKU <> GROUP BY Department ORDER BY Dept_SKU_Count; What happens when you run this query? KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

8 The SQL Keyword GROUP BY
SELECT Department, COUNT(*) AS Dept_SKU_Count FROM SKU_DATA WHERE SKU <> GROUP BY Department ORDER BY Dept_SKU_Count; ORDER BY Count(*); KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

9 The SQL Keyword GROUP BY
In general, place WHERE before GROUP BY. Some DBMS products do not require that placement; but to be safe, always put WHERE before GROUP BY. The HAVING operator restricts the groups that are presented in the result. There is an ambiguity in statements that include both WHERE and HAVING clauses. The results can vary, so to eliminate this ambiguity SQL always applies WHERE before HAVING. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

10 Having SELECT Department, COUNT(*) AS Dept_SKU_Count FROM SKU_DATA
WHERE SKU <> GROUP BY Department HAVING COUNT (*) > 1 ORDER BY COUNT(*); KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall

11 Querying Multiple Tables: Joins
What if the information I seek is in multiple tables? For example, I want to know the buyer name and extended price for each item ordered?

12 Querying Multiple Tables: Joins
SELECT Buyer, ExtendedPrice FROM SKU_DATA, ORDER_ITEM WHERE SKU_DATA.SKU = ORDER_ITEM.SKU; What if I want the total of all ExtendedPrice values for each buyer? Also, sort the results by total ExtendedPrice in descending order. KROENKE AND AUER - DATABASE PROCESSING, 12th Edition © 2012 Pearson Prentice Hall


Download ppt "CSIS 115 Database Design and Applications for Business"

Similar presentations


Ads by Google