-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62435be
commit 7d8e31c
Showing
16 changed files
with
858 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
05_analyze-data/04_performing-data-calculations/activity/query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- set up temporary table | ||
WITH trees_temp AS ( | ||
SELECT * | ||
FROM ( | ||
SELECT * | ||
FROM bigquery-public-data.new_york_trees.tree_census_1995 | ||
JOIN bigquery-public-data.new_york_trees.tree_census_2005 | ||
ON tree_census_1995.diameter = tree_census_2005.tree_dbh | ||
WHERE diameter > 30 | ||
) | ||
) | ||
|
||
-- count large trees greater than 30 inches across | ||
SELECT COUNT(*) AS COUNT | ||
FROM trees_temp |
31 changes: 31 additions & 0 deletions
31
05_analyze-data/04_performing-data-calculations/files/Cosmetics-Inc.---Sheet1.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Product Codes,Price,Client,Client Code,Orders,Total,,Left,Right,Mid,Trim | ||
51993Masc,$9.98,Candy's Beauty Supply,PINNC980,191,"$1,906.18",,51993,Masc,NC,Candy's Beauty Supply | ||
49631Foun,$14.49,Rockland's,ARLVA283,152,"$2,202.48",,49631,Foun,VA,Rockland's | ||
42292Glos,$6.74,Rudiger Pharmacy,CHEMD763,758,"$5,108.92",,42292,Glos,MD,Rudiger Pharmacy | ||
86661Shad,$5.71,Elizabethtown Supply,COLSC761,308,"$1,758.68",,86661,Shad,SC,Elizabethtown Supply | ||
49541Eyel,$7.94,Rockland's,ARLVA425,50,$397.00,,49541,Eyel,VA,Rockland's | ||
58337Foun,$13.57,Candy's Beauty Supply,PINNC939,673,"$9,132.61",,58337,Foun,NC,Candy's Beauty Supply | ||
40014Masc,$8.46,Elizabethtown Supply,COLSC649,94,$795.24,,40014,Masc,SC,Elizabethtown Supply | ||
86139Lips,$5.55,Candy's Beauty Supply,PINNC496,299,"$1,659.45",,86139,Lips,NC,Candy's Beauty Supply | ||
69601Exfo,$11.05,Rockland's,ARLVA851,850,"$9,392.50",,69601,Exfo,VA,Rockland's | ||
25331Glos,$7.58,Rockland's,ARLVA924,169,"$1,281.02",,25331,Glos,VA,Rockland's | ||
85021Foun,$11.75,Rudiger Pharmacy,CHEMD339,707,"$8,307.25",,85021,Foun,MD,Rudiger Pharmacy | ||
69030Masc,$10.95,Elizabethtown Supply,COLSC970,461,"$5,047.95",,69030,Masc,SC,Elizabethtown Supply | ||
13230Masc,$11.73,Rockland's,ARLVA519,78,$914.94,,13230,Masc,VA,Rockland's | ||
91559Eyel,$6.66,Candy's Beauty Supply,PINNC674,444,"$2,957.04",,91559,Eyel,NC,Candy's Beauty Supply | ||
62289Masc,$12.06,Elizabethtown Supply,COLSC887,797,"$9,611.82",,62289,Masc,SC,Elizabethtown Supply | ||
64762Foun,$12.95,Rudiger Pharmacy,CHEMD913,355,"$4,597.25",,64762,Foun,MD,Rudiger Pharmacy | ||
52341Foun,$13.09,Elizabethtown Supply,COLSC741,232,"$3,036.88",,52341,Foun,SC,Elizabethtown Supply | ||
68713Exfo,$15.77, Rockland's,ARLVA727,514,"$8,105.78",,68713,Exfo,VA,Rockland's | ||
35073Foun,$11.82,Elizabethtown Supply,COLSC813,189,"$2,233.98",,35073,Foun,SC,Elizabethtown Supply | ||
17691Masc,$11.22,Elizabethtown Supply,COLSC533,621,"$6,967.62",,17691,Masc,SC,Elizabethtown Supply | ||
03485Eyel,$7.00,Rudiger Pharmacy,CHEMD887,461,"$3,227.00",,03485,Eyel,MD,Rudiger Pharmacy | ||
26156Foun,$12.01,Candy's Beauty Supply,PINNC615,146,"$1,753.46",,26156,Foun,NC,Candy's Beauty Supply | ||
75112Foun,$13.24,Elizabethtown Supply,COLSC133,261,"$3,455.64",,75112,Foun,SC,Elizabethtown Supply | ||
96799Foun,$10.07,Rudiger Pharmacy,CHEMD365,602,"$6,062.14",,96799,Foun,MD,Rudiger Pharmacy | ||
20559Shad,$4.33,Elizabethtown Supply,COLSC201,225,$974.25,,20559,Shad,SC,Elizabethtown Supply | ||
32729Masc,$13.13,Elizabethtown Supply,COLSC481,972,"$12,762.36",,32729,Masc,SC,Elizabethtown Supply | ||
63094Exfo,$16.94,Candy's Beauty Supply,PINNC547,362,"$6,132.28",,63094,Exfo,NC,Candy's Beauty Supply | ||
61207Foun,$9.83,Rudiger Pharmacy,CHEMD323,588,"$5,780.04",,61207,Foun,MD,Rudiger Pharmacy | ||
17269Masc,$14.95,Rockland's,ARLVA876,381,"$5,695.95",,17269,Masc,VA,Rockland's | ||
15143Exfo,$20.04,Rudiger Pharmacy,CHEMD584,782,"$15,671.28",,15143,Exfo,MD,Rudiger Pharmacy |
Binary file added
BIN
+243 KB
05_analyze-data/04_performing-data-calculations/files/Your-Intermediate-Guide-to-SQL.pdf
Binary file not shown.
225 changes: 225 additions & 0 deletions
225
...lyze-data/04_performing-data-calculations/graded-assessment/course-challenge.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
## Course challenge | ||
|
||
Latest Submission Grade: 100% | ||
|
||
| ||
|
||
### Scenario 1, Questions 1-7 | ||
|
||
|
||
|
||
For the past six months, you have been working for a direct-mail marketing firm as a junior marketing analyst. Direct mail is advertising material sent to people through the mail. These people can be current or prospective customers, clients, or donors. Many charities depend on direct mail for financial support. | ||
|
||
Your company, Directly Dynamic, creates direct-mail pieces with its in-house staff of graphic designers, expert mail list services, and on-site printing. Your team has just been hired by a local nonprofit, Food Justice Rock Springs. The mission of Food Justice Rock Springs is to eliminate food deserts by establishing local gardens, providing mobile pantries, educating residents, and more. Click below to read the email from Tayen Bell, vice president of marketing and outreach. | ||
|
||
[C5 Course Challenge, Email From Tayen Bell, Directly Dynamic.pdf](files/C5-Course-Challenge-Email-From-Tayen-Bell-Directly-Dynamic-.pdf) | ||
|
||
You begin by reviewing the dataset. | ||
|
||
You may click the link to create a copy of the dataset: [Dynamic Dataset](files/Dynamic-Dataset.xlsx). | ||
|
||
The client has asked you to send two separate mailings: one to people within 50 miles of Rock Springs; the other to anyone outside that area. So, to research each donor’s distance from the city, you first need to find out where all of these people live. | ||
|
||
You could scroll through 209 rows of data, but you know there is a more efficient way to organize the cities. | ||
|
||
**Which of the following tools will enable you to sort your spreadsheet by city (Column K) in ascending order?** | ||
|
||
* Sort Sheet by Column K from Z to Z | ||
* **Sort Sheet by Column K from A to Z** | ||
* Sort Range by Column K from A to Z | ||
* Sort Range by Column K from Z to A | ||
|
||
> To sort your spreadsheet by city in ascending order, Sort Sheet by Column K from A to Z. You can also use the SORT function syntax =SORT(A2:R210, 11, TRUE). | ||
| ||
|
||
### Question 2 | ||
|
||
You notice that many cells in the city column, Column K, are missing a value. So, you use the zip codes to research the correct cities. Now, you want to add the cities to each donor’s row. However, you are concerned about making a mistake, such as a spelling typo. | ||
|
||
**Fill in the blank: To add drop-down lists to your worksheet with predetermined options for each city name, you decide to use _____.** | ||
|
||
* the LIST function | ||
* VLOOKUP | ||
* **data validation** | ||
* the find tool | ||
|
||
> You decide to use data validation. Data validation allows you to control what can and cannot be entered in your worksheet in order to avoid typos. It does this by adding drop-down lists with predetermined options, such as each city name. | ||
| ||
|
||
### Question 3 | ||
|
||
Now, you decide to address Tayen’s request to include a handwritten note in the direct-mail piece for anyone who gave at least $100 last year. | ||
|
||
**Which of the following spreadsheet tools will enable you to change how cells appear if they contain a value of $100 or more?** | ||
|
||
* **Conditional formatting** | ||
* The MAX function | ||
* The COUNTA function | ||
* Data validation | ||
|
||
> To change how cells appear, use conditional formatting. Choose to format cells if they are greater than or equal to 100. | ||
| ||
|
||
### Question 4 | ||
|
||
At this point, you notice that the information about state and zip code is in the same row. However, your company’s mailing list software requires states to be on a separate line from zip codes. | ||
|
||
**What function will enable you to move the 2-character state abbreviation in cell L2 into its own column?** | ||
|
||
* **=LEFT(L2,2)** | ||
* =LEFT(2,L2) | ||
* =RIGHT(2,L2) | ||
* =RIGHT(L2,2) | ||
|
||
> To move the 2-character state abbreviations in Column L into their own column, use the LEFT function: =LEFT(L2,2). | ||
| ||
|
||
### Question 5 | ||
|
||
Next, you duplicate your dataset twice using the Sheet Menu. You rename the first sheet Donation Form List, and you remove the cities that are further than 50 miles from Rock Springs. You rename the second sheet Postcard List, and you remove the cities that are within 50 miles of Rock Springs. | ||
|
||
Then, you import these datasets into your company’s mailing list database. In a mailing list database, you create two tables: Donation_Form_List and Postcard_List. You decide to clean the Donation_Form_List first. | ||
|
||
Your company’s mailing list software requires units to be on the same line as street addresses. However, they are currently in two separate columns (street_address and unit). | ||
|
||
**What portion of your SQL statement will instruct the database to combine these two columns into a new column called “address”?** | ||
|
||
* JOIN(street_address to unit) AS address | ||
* JOIN(street_address, " to ", unit) AS address | ||
* CONCAT(street_address to unit) AS address | ||
* **CONCAT(street_address, " to ", unit) as address** | ||
|
||
> The portion of your SQL statement used to instruct the database to combine these two columns into a new column called “address” is CONCAT(street_address, " to ", unit) AS address. | ||
| ||
|
||
### Question 6 | ||
|
||
Your database contains people who live in many areas of Wyoming. However, it’s important to align your in-house data with the data from Food Justice Rock Springs. You also need to separate your data into the two lists: Donation_Form_List and Postcard_List. They will be based on each city’s distance from Rock Springs. | ||
|
||
**The zip codes are in a column called zip_code. To select all data from the Donation_Form_List organized by zip code, you use the ORDER BY function. The syntax is:** | ||
|
||
``` | ||
SELECT * FROM Donation_Form_List ORDER BY zip_code | ||
``` | ||
|
||
* **True** | ||
* False | ||
|
||
> To organize your data by zip code, the correct query is: `SELECT * FROM Donation_Form_List ORDER BY zip_code` | ||
| ||
|
||
### Question 7 | ||
|
||
You finish cleaning your datasets, so you decide to review Tayen’s email one more time to make sure you completed the task fully. It’s a good thing you checked because you forgot to identify people who have served on the board of directors or board of trustees. She wants to write them a thank-you note, so you need to locate them in the database. | ||
|
||
**To retrieve only those records that include people who have served on the board of trustees or on the board of directors, you use the WHERE function. The syntax is:** | ||
|
||
* True | ||
* **False** | ||
|
||
> To retrieve only those records that include people who have served on the board of trustees or on the board of directors, the syntax must include “OR.” Including “AND” will only retrieve records of people who served on both boards. The syntax is: | ||
| ||
|
||
## Scenario 2, continued | ||
|
||
### Question 8 | ||
|
||
Your company’s direct-mail campaign was very successful, and Food Justice Rock Springs has continued partnering with Directly Dynamic. One thing you’ve been working on is assigning all donors identification numbers. This will enable you to clean and organize the lists more effectively. | ||
|
||
Meanwhile, another team member has been creating a prospect list that contains data about people who have indicated interest in getting involved with Food Justice Rock Springs. These people are also assigned a unique ID. Now, you need to compare your donor list with the dataset in your database and collect certain data from both. | ||
|
||
**What SQL function will return all records from the left table and only the matching records from the right?** | ||
|
||
* OUTER JOIN | ||
* INNER JOIN | ||
* RIGHT JOIN | ||
* **LEFT JOIN** | ||
|
||
> A LEFT JOIN function will return all records from the left table and only the matching records from the right. | ||
| ||
|
||
### Question 9 | ||
|
||
|
||
Your next task is to identify the average contribution given by donors over the past two years. Tayen will use this information to set a donation minimum for inviting donors to an upcoming event. | ||
|
||
**You start with 2019. To return average contributions in 2019 (contributions_2019), you use the AVG function. What portion of your SQL statement will instruct the database to find this average and store it in the AvgLineTotal variable?** | ||
|
||
* `AVG (“contributions_2019”) IN AvgLineTotal` | ||
* `AVG (“contributions_2019”) AS AvgLineTotal` | ||
* **`AVG (contributions_2019) AS AvgLineTotal`** | ||
* `AVG (contributions_2019) = “AvgLineTotal”` | ||
|
||
> To return average contributions in 2019, the correct portion of the SQL query is: `AVG (contributions_2019) AS AvgLineTotal` | ||
| ||
|
||
### Question 10 | ||
|
||
Now that you provided her with the average donation amount, Tayen decides to invite 50 people to the grand opening of a new community garden. You return to your New Donor List spreadsheet to determine how much each donor gave in the past two years. You will use that information to identify the 50 top donors and invite them to the event. | ||
|
||
**What is the correct syntax to add the contribution amounts in cells O2 and P2?** | ||
|
||
* =SUM(“O2,P2”) | ||
* =SUM(O2*P2) | ||
* =SUM(O2/P2) | ||
* **=SUM(O2,P2)** | ||
|
||
> To add cells O2 and P2, use the function =SUM(O2,P2). You can also use the formula =O2+P2. | ||
| ||
|
||
### Question 11 | ||
|
||
Tayen informs you that she’s thinking about inviting anyone who donated at least $100 in 2018, as well. However, she only has five open spaces. She asks you to report how many people gave at least $100 so she can determine if they can also be invited to the event. | ||
|
||
**What is the correct syntax to count how many donations of $100 or greater appear in Column Q (Contributions 2018)?** | ||
|
||
* **=COUNTIF(Q2:Q210,">=100")** | ||
* =COUNTIF(Q2:Q210>=100) | ||
* =COUNTIF(Q2:Q210,>=100) | ||
* =COUNTIF(Q2:Q210">=100") | ||
|
||
> To count how many donations of $100 or greater appear in Column Q, the correct syntax is =COUNTIF(Q2:Q210,">=100"). | ||
| ||
|
||
### Question 12 | ||
|
||
The community garden grand opening was a success. In addition to the 55 donors Food Justice Rock Springs invited, 20 other prospects attended the event. Now, Tayen wants to know the percentage of donations that came in that day from the new prospects compared to the original donors. | ||
|
||
**Which SQL query can be used to calculate the percentage of contributions from prospects?** | ||
|
||
* SELECT event_contributions, Total_donors, Total_prospects, ("Total_prospects" / "Total_donors" * 100) AS Prospects_Percent FROM contributions_data | ||
* SELECT event_contributions, Total_donors, Total_prospects, (Total_prospects / Total_donors x 100) AS Prospects_Percent FROM contributions_data | ||
* **SELECT event_contributions, Total_donors, Total_prospects, (Total_prospects / Total_donors * 100) AS Prospects_Percent FROM contributions_data** | ||
* SELECT event_contributions, Total_donors, Total_prospects, (Total_prospects AND Total_donors = 100) AS Prospects_Percent FROM contributions_data | ||
|
||
> To identify the percentage of contributions from prospects, the correct query is: `SELECT event_contributions, Total_donors, Total_prospects, (Total_prospects / Total_donors * 100) AS Prospects_Percent FROM contributions_data` | ||
| ||
|
||
### Question 13 | ||
|
||
Your team creates a highly effective prospects list for Food Justice Rock Springs. After a few months, many of these prospects become donors. Now, Tayen wants to know the top three cities in which these new donors live. She will use that information to determine if it’s still true that people who live closer to Rock Springs are more likely to donate. | ||
|
||
**What clause do you add to the following query to sort the donors in each city from high to low?** | ||
|
||
``` | ||
SELECT COUNT (DonorID), City FROM new_donor_list GROUP BY City | ||
``` | ||
|
||
* ORDER BY CITY(DonorID) ASC | ||
* ORDER BY COUNT(DonorID) ASC | ||
* ORDER BY CITY(DonorID) DESC | ||
* **ORDER BY COUNT(DonorID) DESC** | ||
|
||
> To retrieve the number of donors in each city, sorted high to low, the correct SQL query is: `SELECT COUNT (DonorID), City FROM new_donor_list GROUP BY City ORDER BY COUNT(DonorID) DESC` |
Binary file added
BIN
+45.6 KB
...s/graded-assessment/files/C5-Course-Challenge-Email-From-Tayen-Bell-Directly-Dynamic-.pdf
Binary file not shown.
Binary file added
BIN
+393 KB
05_analyze-data/04_performing-data-calculations/graded-assessment/files/Dynamic-Dataset.xlsx
Binary file not shown.
Binary file added
BIN
+140 KB
...a/04_performing-data-calculations/graded-assessment/files/Movie-Data-Starter-Project.xlsx
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
...ions/graded-assessment/files/Sample-Transaction-Table---transactional-data-format-csv.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
date,transaction_id,customer_id,product,product_code,product_color,product_price,purchase_size,purchase_price | ||
2020-08-29,9900,1980,fan,SKU83503,brass,$13.99,2,$27.98 | ||
2020-05-01,12315,2463,fan,SKU83503,brass,$13.99,2,$27.98 | ||
2020-12-12,9890,1978,fan,SKU83503,white,$13.99,1,$13.99 | ||
2020-02-16,46915,9383,fan,SKU83503,black,$13.99,1,$13.99 | ||
2020-12-28,44700,8940,fan,SKU83503,brass,$13.99,2,$27.98 | ||
2020-12-28,44700,8940,lamp,SKU95363,brass,$45.99,5,$160.97 | ||
2020-10-11,12560,2512,bed,SKU74796,brown,$799.99,1,$799.99 | ||
2020-06-29,9640,1928,couch,SKU31871,grey,"$1,000.00",1,"$1,000.00" | ||
2020-11-10,22620,4524,couch,SKU31871,grey,"$1,000.00",1,"$1,000.00" | ||
2020-02-05,49430,9886,couch,SKU31871,grey,"$1,000.00",1,"$1,000.00" | ||
2020-04-28,49075,9815,couch,SKU31871,blue,"$1,000.00",1,"$1,000.00" | ||
2020-01-23,37855,7571,couch,SKU31871,purple,"$1,000.00",1,"$1,000.00" | ||
2020-02-16,9900,1980,couch,SKU31871,white,"$1,000.00",1,"$1,000.00" | ||
2020-10-12,1675,335,couch,SKU31871,white,"$1,000.00",1,"$1,000.00" | ||
2020-07-08,23435,4687,couch,SKU31871,brown,"$1,000.00",1,"$1,000.00" | ||
2020-10-21,19105,3821,couch,SKU31871,black,"$1,000.00",1,"$1,000.00" | ||
2020-12-30,48035,9607,rug,SKU19092,beige,$89.85,3,$269.55 | ||
2020-09-25,31615,6323,rug,SKU19092,grey,$89.85,2,$179.70 | ||
2020-08-11,31775,6355,rug,SKU19092,grey,$89.85,1,$89.85 | ||
2020-09-07,21870,4374,rug,SKU19092,beige,$89.85,3,$269.55 | ||
2020-07-22,45400,9080,vase,SKU99037,green,$9.99,2,$19.98 | ||
2020-07-22,45400,9080,mirror,SKU97721,brass,$199.95,1,$199.95 | ||
2020-07-22,45400,9080,bookcase,SKU15757,brown,$58.89,1,$58.89 | ||
2020-04-29,26530,5306,desk,SKU40294,brown,$169.95,1,$169.95 | ||
2020-03-22,14080,2816,desk,SKU40294,brown,$169.95,1,$169.95 | ||
2020-06-04,6340,1268,desk,SKU40294,white,$169.95,1,$169.95 | ||
2020-02-28,21485,4297,chair,SKU99664,black,$234.50,1,$234.50 | ||
2020-06-06,24785,4957,chaise,SKU77417,beige,$399.95,1,$399.95 | ||
2020-06-06,24785,4957,ottoman,SKU13351,grey,$299.99,1,$299.99 |
Oops, something went wrong.