0% found this document useful (0 votes)
0 views

Week 3 - SQL Continued (1) (2) (2)

Uploaded by

chettiarpatricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Week 3 - SQL Continued (1) (2) (2)

Uploaded by

chettiarpatricia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Welcome!

We’ll give everyone a few minutes to get online.

While we wait, please feel free to share (and discuss)


your answer to the following question via chat:

What skill or talent have you always wanted to learn


or develop?
PROGRAMMING
FUNDAMENTALS
FOR ANALYTICS
WEEK 3 – SQL Continued
LEARNING OBJECTIVES

01 Summarize data
02 Group Data
03 Join 2 unique tables
04 SQL Having
01
Summarize Data
SELECT Explanation
• SELECT: Specifies the columns to retrieve.
• COUNT(*): Counts the number of sales for each
COUNT(*) AS total_sales, product.
SUM(amount) AS total_amount, • SUM(amount): Sums up the total sales amount for
AVG(amount) AS average_amount, each product.
MAX(amount) AS max_sale, • AVG(amount): Calculates the average sale amount
MIN(amount) AS min_sale for each product.
• MAX(amount): Finds the maximum sale amount for
FROM
each product.
sales • MIN(amount): Finds the minimum sale amount for
each product.
• FROM: Specifies the table from which to select the
data.
02
Group Data
SELECT column_name(s) SELECT COUNT(ProductID), SupplierID
FROM table_name FROM Products
WHERE condition Where Price > 15
GROUP BY column_name(s) GROUP BY SupplierID
ORDER BY column_name(s); ORDER BY COUNT(ProductID) DESC;
03
Join 2
Unique Tables
Joins Explained
Inner Join

SELECT columns
FROM table1
INNER JOIN table2
ON table1.common_column = table2.common_column;

SELECT employees.name, departments.department_name


FROM employees
INNER JOIN departments
ON employees.department_id = departments.id;

Replace INNER JOIN by LEFT JOIN, RIGHT JOIN, OUTER JOIN for other joins
Joins Explained
SQL Having
Having Example

SELECT COUNT(CustomerID),
Country
FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 5
ORDER BY COUNT(CustomerID) DES
C;
THAT’S A
WRAP
ACTION PLAN
● Complete assigned reading as
required
● Watch the assigned video as
required
● Complete all assigned activities
and submit via blackboard by
due date
</>
Reading Homework
Chapters 9 – 12 Assignment 1 - SQL
Sam’s Teach Yourself
SQL in 10 Minutes
QUESTIONS?
THE END
BREAK

You might also like