From 697dfc599a07a32ca667b2548434df831241370a Mon Sep 17 00:00:00 2001 From: Stephanie Shishis Date: Thu, 26 Mar 2026 12:22:17 -0400 Subject: [PATCH 1/2] Module #2 live code --- .../live_code/module_2/module_2.sqbpro | 457 +++++++++++------- 1 file changed, 278 insertions(+), 179 deletions(-) diff --git a/04_this_cohort/live_code/module_2/module_2.sqbpro b/04_this_cohort/live_code/module_2/module_2.sqbpro index 06850fe25..d24709b5d 100644 --- a/04_this_cohort/live_code/module_2/module_2.sqbpro +++ b/04_this_cohort/live_code/module_2/module_2.sqbpro @@ -1,179 +1,278 @@ -
/* MODULE 2 */ -/* SELECT */ - - -/* 1. Select everything in the customer table */ -SELECT - -/* 2. Use sql as a calculator */ - - - -/* 3. Add order by and limit clauses */ - - - -/* 4. Select multiple specific columns */ - - - -/* 5. Add a static value in a column */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* WHERE */ - -/* 1. Select only customer 1 from the customer table */ -SELECT * -FROM customer -WHERE - - -/* 2. Differentiate between AND and OR */ - - - -/* 3. IN */ - - - -/* 4. LIKE */ - - - -/* 5. Nulls and Blanks*/ - - - -/* 6. BETWEEN x AND y */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* CASE */ - - -SELECT * -/* 1. Add a CASE statement declaring which days vendors should come */ - - -/* 2. Add another CASE statement for Pie Day */ - - - -/* 3. Add another CASE statement with an ELSE clause to handle rows evaluating to False */ - - - -/* 4. Experiment with selecting a different column instead of just a string value */ - - -FROM vendor - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* DISTINCT */ - - -/* 1. Compare how many customer_ids are the customer_purchases table, one select with distinct, one without */ - --- 4221 rows -SELECT customer_id FROM customer_purchases - - - -/* 2. Compare the difference between selecting market_day in market_date_info, with and without distinct: - what do these difference mean?*/ - - - -/* 3. Which vendor has sold products to a customer */ - - - -/* 4. Which vendor has sold products to a customer ... and which product was it */ - - - -/* 5. Which vendor has sold products to a customer -... and which product was it? -... AND to whom was it sold*/ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* INNER JOIN */ - - -/* 1. Get product names (from product table) alongside customer_purchases - ... use an INNER JOIN to see only products that have been purchased */ - --- without table aliases - - - - -/* 2. Using the Query #4 from DISTINCT earlier - (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) - - Add customers' first and last names with an INNER JOIN */ - --- using table aliases - - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* LEFT JOIN */ - - -/* 1. There are products that have been bought -... but are there products that have not been bought? -Use a LEFT JOIN to find out*/ - - -/* 2. Directions of LEFT JOINs matter ...*/ - - - - -/* 3. As do which values you filter on ... */ - - - - -/* 4. Without using a RIGHT JOIN, make this query return the RIGHT JOIN result set -...**Hint, flip the order of the joins** ... - -SELECT * - -FROM product_category AS pc -LEFT JOIN product AS p - ON pc.product_category_id = p.product_category_id - ORDER by pc.product_category_id - -...Note how the row count changed from 24 to 23 -*/ - - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ -/* Multiple Table JOINs */ - - -/* 1. Using the Query #4 from DISTINCT earlier - (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) - - Replace all the IDs (customer, vendor, and product) with the names instead*/ - - - -/* 2. Select product_category_name, everything from the product table, and then LEFT JOIN the customer_purchases table -... how does this LEFT JOIN affect the number of rows? - -Why do we have more rows now?*/ - -
+/* MODULE 2 */ +/* SELECT */ + + +/* 1. Select everything in the customer table */ +SELECT * FROM customer; + +/* 2. Use sql as a calculator */ +SELECT 1+1 AS addiiton, 10*5 AS multiplication, pi() AS pi; + + +/* 3. Add order by and limit clauses */ +SELECT * +FROM customer +ORDER BY customer_first_name +LIMIT 10; + +/* 4. Select multiple specific columns */ +SELECT customer_first_name, customer_last_name +FROM customer; + + +/* 5. Add a static value in a column */ +SELECT 2026 AS this_year, 'March' AS this_month, customer_id +FROM customer + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* WHERE */ + +/* 1. Select only customer 1 from the customer table */ +SELECT * +FROM customer +WHERE customer_id = 1; + + +/* 2. Differentiate between AND and OR */ +SELECT * +FROM customer +WHERE customer_id = 1 +OR customer_id = 2; -- OR is two rows, AND is 0 rows + + +/* 3. IN */ +SELECT * +FROM customer +WHERE customer_id IN (3,4,5,6); + + +/* 4. LIKE */ +-- all the peppers +SELECT * FROM product +WHERE product_name LIKE '%pepper%'; + +/* 5. Nulls and Blanks*/ +SELECT * +FROM product +WHERE product_size IS NULL +OR product_size = '';--blank,two single quotes not one double quote, different from NULL + + +/* 6. BETWEEN x AND y */ +SELECT * +FROM customer +WHERE customer_id BETWEEN 1 AND 20; +--dates + +SELECT * +FROM market_date_info +WHERE market_date BETWEEN '2022-10-01'AND'2022-10-31'; + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* CASE */ + + +SELECT * +/* 1. Add a CASE statement declaring which days vendors should come */ +,CASE WHEN vendor_type = 'Fresh Focused' THEN 'Wednesday' + WHEN vendor_type = 'Eggs & Meat' THEN 'Thursday' + ELSE 'Saturday' + END as day_of_specialty + + +/* 2. Add another CASE statement for Pie Day */ +,CASE WHEN vendor_name = "Annie's Pies" --double quotes okay here + THEN 'Annie is the best' + END AS pi_day + + +/* 3. Add another CASE statement with an ELSE clause to handle rows evaluating to False */ +, CASE WHEN vendor_name LIKE '%pie%' + THEN 'Wednesday' + ELSE 'Friday' + END AS another_pie_day + +FROM vendor; + + +/* 4. Experiment with selecting a different column instead of just a string value */ + +SELECT * +,CASE WHEN cost_to_customer_per_qty <1.00 +THEN cost_to_customer_per_qty*5 +ELSE cost_to_customer_per_qty +END AS inflation + +FROM customer_purchases + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* DISTINCT */ + + +/* 1. Compare how many customer_ids are the customer_purchases table, one select with distinct, one without */ + +-- 4221 rows +SELECT customer_id FROM customer_purchases; + +SELECT DISTINCT customer_id FROM customer_purchases; + + + +/* 2. Compare the difference between selecting market_day in market_date_info, with and without distinct: + what do these difference mean?*/ +SELECT market_day +FROM market_date_info; + +-- market is only open on 2 days, wed and sat + +SELECT DISTINCT market_day +FROM market_date_info; + + +/* 3. Which vendor has sold products to a customer */ +SELECT DISTINCT vendor_id +FROM customer_purchases; + + +/* 4. Which vendor has sold products to a customer ... and which product was it */ +SELECT DISTINCT vendor_id, product_id +FROM customer_purchases; + + +/* 5. Which vendor has sold products to a customer +... and which product was it? +... AND to whom was it sold*/ +SELECT DISTINCT vendor_id, product_id, customer_id +FROM customer_purchases; + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* INNER JOIN */ + + +/* 1. Get product names (from product table) alongside customer_purchases + ... use an INNER JOIN to see only products that have been purchased */ + +-- without table aliases +SELECT product_name, -- coming from the product table +vendor_id, -- rest of these are coming from the customer_purchases table +market_date, +customer_id, +customer_purchases.product_id, +product.product_id + +FROM product +INNER JOIN customer_purchases + ON customer_purchases.product_id = product.product_id; + + +/* 2. Using the Query #5 from DISTINCT earlier + (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) + + Add customers' first and last names with an INNER JOIN */ + +-- using table aliases + +SELECT DISTINCT +vendor_id, -- coming from cp +product_id, +c.customer_id, -- coming from c (customer) +customer_first_name, +customer_last_name + +FROM customer_purchases AS cp +INNER JOIN customer AS C + ON c.customer_id = cp.customer_id + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* LEFT JOIN */ + + +/* 1. There are products that have been bought +... but are there products that have not been bought? +Use a LEFT JOIN to find out*/ + +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id; + +-- NULL product has not been bought, there is no product id in the customer purchases + + +/* 2. Directions of LEFT JOINs matter ...*/ + +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM customer_purchases as cp +LEFT JOIN product as p + ON p.product_id = cp.product_id; + +-- no number in customer purchases to begin with so will not be included + +/* 3. As do which values you filter on ... */ + +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id + +WHERE p.product_id BETWEEN 1 AND 6; -- if we pick product, 6 rows (1-6) but if we pick cp...only 5 rows because zinnias never existed in customer_purchases + +/* 4. Without using a RIGHT JOIN, make this query return the RIGHT JOIN result set +...**Hint, flip the order of the joins** ... + +SELECT * + +FROM product_category AS pc +LEFT JOIN product AS p + ON pc.product_category_id = p.product_category_id + ORDER by pc.product_category_id + +...Note how the row count changed from 24 to 23 +*/ + +SELECT * +FROM product AS P +LEFT JOIN product_category AS pc + ON pc.product_category_id = p.product_category_id + ORDER by pc.product_category_id + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 2 */ +/* Multiple Table JOINs */ + + +/* 1. Using the Query #4 from DISTINCT earlier + (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) + + Replace all the IDs (customer, vendor, and product) with the names instead*/ + + + +/* 2. Select product_category_name, everything from the product table, and then LEFT JOIN the customer_purchases table +... how does this LEFT JOIN affect the number of rows? + +Why do we have more rows now?*/ + + From b561777db37c7540c1fd884713b995d654850605 Mon Sep 17 00:00:00 2001 From: Stephanie Shishis Date: Tue, 31 Mar 2026 17:36:30 -0400 Subject: [PATCH 2/2] Assignment One Completed --- .../assignments/DC_Cohort/Assignment1.md | 13 +- .../Section1_LogicalDataModel.drawio | 40 ++ .../DC_Cohort/Section1_LogicalDataModel.pdf | Bin 0 -> 28347 bytes .../assignments/DC_Cohort/assignment1.sql | 101 ++-- .../live_code/module_2/module_2.sqbpro | 152 +++--- .../live_code/module_3/module_3.sqbpro | 500 +++++++++++------- 6 files changed, 522 insertions(+), 284 deletions(-) create mode 100644 02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.drawio create mode 100644 02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.pdf diff --git a/02_activities/assignments/DC_Cohort/Assignment1.md b/02_activities/assignments/DC_Cohort/Assignment1.md index f650c9752..116026411 100644 --- a/02_activities/assignments/DC_Cohort/Assignment1.md +++ b/02_activities/assignments/DC_Cohort/Assignment1.md @@ -207,7 +207,14 @@ Link if you encounter a paywall: https://archive.is/srKHV or https://web.archive Consider, for example, concepts of fariness, inequality, social structures, marginalization, intersection of technology and society, etc. +There are a lot of value systems that are in databases/data systems that I encounter in my day-to-day life. Often, I do not think of these systems but after reading this article, these systems are so important in how databases are created and how society functions. -``` -Your thoughts... -``` +The most immediate example I can think of is for any government id or identity/account creation. Most databases include only legal names and binary gender fields (although this has now changed to X for example on passports to include everyone who does not fit into this binary system). This is still stringent as there could be more flexibility for chosen names or even within in the non-binary category, X does not encompass all of the differences within this category. + +Similarly, for a lot of surveys I complete. Often race/ethnicity options have an 'Other' category, income brackets are centered around middle-class assumptions, marital status does not account for common law or other non-traditional relationships etc. These are all categories, while improving, could be expanded on instead of provided binary options. + +Another example I really thought about was banking. Historically, until the late 70s, women could not open a credit card in their own name unless there was a male cosign. This would have impacted databases and significant reform would have had to happen to ensure the system would allow me to bank as I do today. + +Lastly for healthcare. A lot of diagnostic tools and symptoms are predominantly based on biological male research data. If medical records and past databases are used to train machine learning tools for improving future healthcare systems, this could be grossly misinterpreting the biological female category or any other non-binary category. + +This article has made me realize that all of these value systems and databases are originally designed around a "normal" or "default" user. When the user differs from this default, it can have large consequences on how the database functions. As technology advances, we need to be aware that not everyone and not every database can assume a default user. diff --git a/02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.drawio b/02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.drawio new file mode 100644 index 000000000..f28929fe6 --- /dev/null +++ b/02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.drawio @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.pdf b/02_activities/assignments/DC_Cohort/Section1_LogicalDataModel.pdf new file mode 100644 index 0000000000000000000000000000000000000000..49e967ca7d6f7bb0ed9931df19ff993caa01098e GIT binary patch literal 28347 zcmbSz1yo$gwl+y{cL>@9cXtaA+})kV-JRer!GaUq-3jglmmmRxyAucwe}~N6;k|qR zyJp^6tkd09b@uu8x2<;3Kq~i6gqD$x1(tMbe|Hs@5x@YjF))Ya;h|SDbF>5kC=`K) zj%GI2jJi@bCT52Emhbc(^`&i$fR>c7^g{MPeMcL60EM)TyP2h>K0PZP13-&H)y&$+ z#>D|3qXb}Npkv?$fCkuDxB;$gELxNR0b5&3peoQn(#(;bm6@H6nGJM{q?nSl6b-=A z%mN4y1sYn|fEEgw+S^zG=^0tr=s;3Hk`?uh_3h36xC!)lIeQx;Cqp3U`HB{1`t%@8 z09K&Ye*y!c27v{s@Q#a#fr*WQnVFG^ft8V&k(z;l9P|TP2U6s}FX7{Z1%i|TF~a;8 zGlu#AMp$}5X#l;9jlGq=X9gv!O6@m^sOrQ3<4Uuy?Me)3_i90NRvEj?#mD7I=2HYSWAWnFCQp= zzcJm<^XVP4KA$bI247{lxjrmM4YM~N%XlwU>$R6Rly+1Ap z{=T(!Y#X*m6kepnp>q{C62kCde+!v_blj|1NZI4`!bq?v~+(RU1k$)-dSws^0Th*E0cvE<@iTUiMM5y`olZ#xxhQ_0v{C+gAKH z0*xikRNZD|{!TM*j_JPPUFQ{z3%K=WH$U>#z>sf_ALxA}z1FL!NDu>jMC6(~WO9)s zp^6(3lMB73!`+88%49!$?!Y98V?GO3-pF4okF>Q&C{Q|D7}?Pob2@tIk+_!jt@cbG zpqxN>^H5Gk0~K7zsl(to_MlE>YaQD3b4JipWFmvXZ5zLtz$%|+(C&=UPs~erOd6}? zlJm{1P{19-Xr=@%_ZLZCP8+_=27{%c*m_grK~F$`{vMII?L-U2Nhc)~GmdsTU$XRw zqty0+A|FDmTv&`2{Di2H>j5-A77=ua)>(WFN<9R5?PU2NDYNvTNm|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zeL{l@p7H|*KYh;ueCugH1W(^f7~((dL;lBjNXThF(El+W@R~hoGaPbyJUHa^cyKtr zB*O3h!eMyg?gK{0Wj)UZ4nPo3wO_7i46!w6q=NaOIA&e^#1@V>@x@e literal 0 HcmV?d00001 diff --git a/02_activities/assignments/DC_Cohort/assignment1.sql b/02_activities/assignments/DC_Cohort/assignment1.sql index 2ec561e2a..2ccfdd397 100644 --- a/02_activities/assignments/DC_Cohort/assignment1.sql +++ b/02_activities/assignments/DC_Cohort/assignment1.sql @@ -2,39 +2,38 @@ --Please write responses between the QUERY # and END QUERY blocks /* SECTION 2 */ - --SELECT /* 1. Write a query that returns everything in the customer table. */ --QUERY 1 - - +SELECT * +FROM customer; --END QUERY - /* 2. Write a query that displays all of the columns and 10 rows from the customer table, sorted by customer_last_name, then customer_first_ name. */ --QUERY 2 - - +SELECT * +FROM customer +ORDER BY customer_last_name, customer_first_name +LIMIT 10; --END QUERY - --WHERE /* 1. Write a query that returns all customer purchases of product IDs 4 and 9. Limit to 25 rows of output. */ --QUERY 3 - - +SELECT * +FROM customer_purchases +WHERE product_id = 4 OR product_id = 9 +LIMIT 25; --END QUERY - - /*2. Write a query that returns all customer purchases and a new calculated column 'price' (quantity * cost_to_customer_per_qty), filtered by customer IDs between 8 and 10 (inclusive) using either: 1. two conditions using AND @@ -43,12 +42,13 @@ Limit to 25 rows of output. */ --QUERY 4 - - +SELECT *, quantity * cost_to_customer_per_qty AS price +FROM customer_purchases +WHERE customer_id BETWEEN 8 and 10 +LIMIT 25; --END QUERY - --CASE /* 1. Products can be sold by the individual unit or by bulk measures like lbs. or oz. Using the product table, write a query that outputs the product_id and product_name @@ -56,36 +56,51 @@ columns and add a column called prod_qty_type_condensed that displays the word if the product_qty_type is “unit,” and otherwise displays the word “bulk.” */ --QUERY 5 - - +SELECT product_id, product_name +, CASE WHEN product_qty_type = 'unit' + THEN 'unit' + ELSE 'bulk' + END AS prod_qty_type_condensed + +FROM product; --END QUERY - /* 2. We want to flag all of the different types of pepper products that are sold at the market. add a column to the previous query called pepper_flag that outputs a 1 if the product_name contains the word “pepper” (regardless of capitalization), and otherwise outputs 0. */ --QUERY 6 - - +SELECT product_id, product_name +, CASE WHEN product_qty_type = 'unit' + THEN 'unit' + ELSE 'bulk' + END AS prod_qty_type_condensed + +, CASE WHEN LOWER(product_name) LIKE '%pepper%' + THEN 1 + ELSE 0 + END AS pepper_flag + +FROM product; --END QUERY - --JOIN /* 1. Write a query that INNER JOINs the vendor table to the vendor_booth_assignments table on the vendor_id field they both have in common, and sorts the result by market_date, then vendor_name. Limit to 24 rows of output. */ --QUERY 7 - - +SELECT * +FROM vendor +INNER JOIN vendor_booth_assignments + ON vendor.vendor_id = vendor_booth_assignments.vendor_id +ORDER BY market_date, vendor_name +LIMIT 24 --END QUERY - - /* SECTION 3 */ -- AGGREGATE @@ -93,12 +108,12 @@ Limit to 24 rows of output. */ at the farmer’s market by counting the vendor booth assignments per vendor_id. */ --QUERY 8 - - +SELECT vendor_id, count(*) AS booth_count +FROM vendor_booth_assignments +GROUP BY vendor_id; --END QUERY - /* 2. The Farmer’s Market Customer Appreciation Committee wants to give a bumper sticker to everyone who has ever spent more than $2000 at the market. Write a query that generates a list of customers for them to give stickers to, sorted by last name, then first name. @@ -106,12 +121,20 @@ of customers for them to give stickers to, sorted by last name, then first name. HINT: This query requires you to join two tables, use an aggregate function, and use the HAVING keyword. */ --QUERY 9 +SELECT + customer_first_name +,customer_last_name +, SUM(quantity*cost_to_customer_per_qty) as total_spend - +FROM customer_purchases as cp +INNER JOIN customer as c + ON c.customer_id = cp.customer_id +GROUP BY cp.customer_id +HAVING total_spend > 2000 +ORDER BY customer_last_name, customer_first_name; --END QUERY - --Temp Table /* 1. Insert the original vendor table into a temp.new_vendor and then add a 10th vendor: Thomass Superfood Store, a Fresh Focused store, owned by Thomas Rosenthal @@ -125,13 +148,20 @@ VALUES(col1,col2,col3,col4,col5) */ --QUERY 10 +-- Created table from the original +CREATE TABLE temp.new_vendor AS +SELECT * +FROM vendor; - +-- Add the 10th vendor +INSERT INTO temp.new_vendor + (vendor_id, vendor_name, vendor_type, vendor_owner_first_name, vendor_owner_last_name) +VALUES + (10, 'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal'); --END QUERY - --- Date +-- Date DO NOT COMPLETE /*1. Get the customer_id, month, and year (in separate columns) of every purchase in the customer_purchases table. HINT: you might need to search for strfrtime modifers sqlite on the web to know what the modifers for month @@ -139,12 +169,8 @@ and year are! Limit to 25 rows of output. */ --QUERY 11 - - - --END QUERY - /* 2. Using the previous query as a base, determine how much money each customer spent in April 2022. Remember that money spent is quantity*cost_to_customer_per_qty. @@ -153,7 +179,4 @@ but remember, STRFTIME returns a STRING for your WHERE statement... AND be sure you remove the LIMIT from the previous query before aggregating!! */ --QUERY 12 - - - --END QUERY diff --git a/04_this_cohort/live_code/module_2/module_2.sqbpro b/04_this_cohort/live_code/module_2/module_2.sqbpro index d24709b5d..c0fec596c 100644 --- a/04_this_cohort/live_code/module_2/module_2.sqbpro +++ b/04_this_cohort/live_code/module_2/module_2.sqbpro @@ -160,15 +160,15 @@ FROM customer_purchases; ... use an INNER JOIN to see only products that have been purchased */ -- without table aliases -SELECT product_name, -- coming from the product table -vendor_id, -- rest of these are coming from the customer_purchases table -market_date, -customer_id, -customer_purchases.product_id, -product.product_id - -FROM product -INNER JOIN customer_purchases +SELECT product_name, -- coming from the product table +vendor_id, -- rest of these are coming from the customer_purchases table +market_date, +customer_id, +customer_purchases.product_id, +product.product_id + +FROM product +INNER JOIN customer_purchases ON customer_purchases.product_id = product.product_id; @@ -177,66 +177,66 @@ INNER JOIN customer_purchases Add customers' first and last names with an INNER JOIN */ --- using table aliases +-- using table aliases -SELECT DISTINCT -vendor_id, -- coming from cp -product_id, -c.customer_id, -- coming from c (customer) -customer_first_name, -customer_last_name - -FROM customer_purchases AS cp -INNER JOIN customer AS C - ON c.customer_id = cp.customer_id +SELECT DISTINCT +vendor_id, -- coming from cp +product_id, +c.customer_id, -- coming from c (customer) +customer_first_name, +customer_last_name + +FROM customer_purchases AS cp +INNER JOIN customer AS C + ON c.customer_id = cp.customer_id -------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +/* MODULE 2 */ /* LEFT JOIN */ /* 1. There are products that have been bought ... but are there products that have not been bought? -Use a LEFT JOIN to find out*/ +Use a LEFT JOIN to find out*/ -SELECT DISTINCT -p. product_id -,cp.product_id as [cp.product_id] -,product_name - -FROM product as p -LEFT JOIN customer_purchases as cp - ON p.product_id = cp.product_id; - --- NULL product has not been bought, there is no product id in the customer purchases +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id; + +-- NULL product has not been bought, there is no product id in the customer purchases -/* 2. Directions of LEFT JOINs matter ...*/ -SELECT DISTINCT -p. product_id -,cp.product_id as [cp.product_id] -,product_name - -FROM customer_purchases as cp -LEFT JOIN product as p - ON p.product_id = cp.product_id; - --- no number in customer purchases to begin with so will not be included +/* 2. Directions of LEFT JOINs matter ...*/ + +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM customer_purchases as cp +LEFT JOIN product as p + ON p.product_id = cp.product_id; -/* 3. As do which values you filter on ... */ +-- no number in customer purchases to begin with so will not be included + +/* 3. As do which values you filter on ... */ -SELECT DISTINCT -p. product_id -,cp.product_id as [cp.product_id] -,product_name - -FROM product as p -LEFT JOIN customer_purchases as cp - ON p.product_id = cp.product_id - +SELECT DISTINCT +p. product_id +,cp.product_id as [cp.product_id] +,product_name + +FROM product as p +LEFT JOIN customer_purchases as cp + ON p.product_id = cp.product_id + WHERE p.product_id BETWEEN 1 AND 6; -- if we pick product, 6 rows (1-6) but if we pick cp...only 5 rows because zinnias never existed in customer_purchases /* 4. Without using a RIGHT JOIN, make this query return the RIGHT JOIN result set @@ -252,14 +252,14 @@ LEFT JOIN product AS p ...Note how the row count changed from 24 to 23 */ -SELECT * -FROM product AS P -LEFT JOIN product_category AS pc - ON pc.product_category_id = p.product_category_id +SELECT * +FROM product AS P +LEFT JOIN product_category AS pc + ON pc.product_category_id = p.product_category_id ORDER by pc.product_category_id -------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 2 */ +/* MODULE 2 */ /* Multiple Table JOINs */ @@ -267,12 +267,38 @@ LEFT JOIN product_category AS pc (Which vendor has sold products to a customer AND which product was it AND to whom was it sold) Replace all the IDs (customer, vendor, and product) with the names instead*/ - +SELECT DISTINCT +--v.vendor_id +,vendor_name +--, p.product_id +, product_name +--, c.customer_id +, customer_first_name +, customer_last_name +FROM customer_purchases AS cp +INNER JOIN vendor AS v + ON v.vendor_id = cp.vendor_id +INNER JOIN product AS p + ON p.product_id = cp.product_id +INNER JOIN customer AS c + ON c.customer_id = cp.customer_id; /* 2. Select product_category_name, everything from the product table, and then LEFT JOIN the customer_purchases table -... how does this LEFT JOIN affect the number of rows? - -Why do we have more rows now?*/ +... how does this LEFT JOIN affect the number of rows? + + Why do we have more rows now?*/ + +SELECT product_category_name, p.* +, cp.product_id as productid_in_cust_purchases_table + +FROM product_category as pc +INNER JOIN product as p -- will give us product_name, product_size, product_qty_type + ON p.product_category_id = pc.product_category_id +LEFT JOIN customer_purchases as cp + ON cp.product_id = p.product_id + + +ORDER by cp.product_id - + diff --git a/04_this_cohort/live_code/module_3/module_3.sqbpro b/04_this_cohort/live_code/module_3/module_3.sqbpro index b580defc7..0dd28b1f0 100644 --- a/04_this_cohort/live_code/module_3/module_3.sqbpro +++ b/04_this_cohort/live_code/module_3/module_3.sqbpro @@ -1,179 +1,321 @@ -

/* MODULE 3 */ -/* COUNT */ - - -/* 1. Count the number of products */ - - - -/* 2. How many products per product_qty_type */ - - - -/* 3. How many products per product_qty_type and per their product_size */ - - - -/* COUNT DISTINCT - 4. How many unique products were bought */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* SUM & AVG */ - - -/* 1. How much did customers spend each day */ - - - -/* 2. How much does each customer spend on average */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* MIN & MAX */ - - -/* 1. What is the most expensive product -...pay attention to how it doesn't handle ties very well -*/ - - -/* 2. Prove that max is working */ - - - -/* 3. Find the minimum price per each product_qty_type */ - - - -/* 4. Prove that min is working */ - - - -/* 5. Min/max on a string -... not particularly useful? */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* Arithmitic */ - - -/* 1. power, pi(), ceiling, division, integer division, etc */ -SELECT - - -/* 2. Every even vendor_id with modulo */ - - - -/* 3. What about every third? */ - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* HAVING */ - - -/* 1. How much did a customer spend on each day? -Filter to customer_id between 1 and 5 and total_cost > 50 -... What order of execution occurs?*/ - - - -/* 2. How many products were bought? -Filter to number of purchases between 300 and 500 */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* Subquery FROM */ - - -/*1. Simple subquery in a FROM statement, e.g. for inflation -...we could imagine joining this to a more complex query perhaps */ - - - - -/* 2. What is the single item that has been bought in the greatest quantity?*/ - - -/* MODULE 3 */ -/* Subquery WHERE */ - - -/* 1. How much did each customer spend at each vendor for each day at the market WHEN IT RAINS */ - - - - -/* 2. What is the name of the vendor who sells pie */ - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* Temp Tables */ - - -/* 1. Put our inflation query into a temp table, e.g. as temp.new_vendor_inventory*/ - -/* some structural code */ -/* ...heads up, sometimes this query can be finnicky -- it's good to try highlighting different sections to help it succeed...*/ - --- if a table named new_vendor_inventory exists, delete it, other do NOTHING -DROP TABLE IF EXISTS temp.new_vendor_inventory; - ---make the table -CREATE TABLE temp.new_vendor_inventory AS - --- definition of the table - - - - - -/* 2. put the previous table into another temp table, e.g. as temp.new_new_vendor_inventory */ - - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* Common Table Expression (CTE) */ - - -/* 1. Calculate sales per vendor per day */ -SELECT - - - - - -/* ... re-aggregate the daily sales for each WEEK instead now */ - - - --------------------------------------------------------------------------------------------------------------------------------------------- -/* MODULE 3 */ -/* Date functions */ - - -/* 1. now */ -SELECT - - -/* 2. strftime */ - - - -/* 3. adding dates, e.g. last date of the month */ - - - -/* 4. difference between dates, - a. number of days between now and each market_date - b. number of YEARS between now and market_date - c. number of HOURS bewtween now and market_date - */ -
+/* MODULE 3 */ +/* COUNT */ + + +/* 1. Count the number of products */ + + SELECT COUNT(product_id) as num_of_products + FROM product; + + +/* 2. How many products per product_qty_type */ + +SELECT product_qty_type, COUNT(product_id) as num_of_products +FROM product +GROUP BY product_qty_type; + +/* 3. How many products per product_qty_type and per their product_size */ + +SELECT product_size +,product_qty_type, +COUNT(product_id) as num_of_products +FROM product +GROUP BY product_size, product_qty_type; + + +/* COUNT DISTINCT + 4. How many unique products were bought */ + +SELECT COUNT(DISTINCT product_id) as bought_products +FROM customer_purchases; + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* SUM & AVG */ + + +/* 1. How much did customers spend each day */ + + SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend + +FROM customer_purchases +GROUP BY market_date, customer_id; + +/* 2. How much does each customer spend on average */ + +SELECT +customer_first_name +,customer_last_name +,ROUND(AVG(quantity*cost_to_customer_per_qty),2) as avg_spend + +FROM customer_purchases as cp +INNER JOIN customer as c + ON c.customer_id = cp.customer_id + +GROUP BY c.customer_id + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* MIN & MAX */ + + +/* 1. What is the most expensive product +...pay attention to how it doesn't handle ties very well +*/ + +SELECT product_name, max(original_price) as most_expensive +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id; + + +/* 2. Prove that max is working */ + +SELECT DISTINCT +product_name, +original_price +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +ORDER BY original_price DESC; + +/* 3. Find the minimum price per each product_qty_type */ + +SELECT product_name +,product_qty_type +,MIN(original_price) + +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +GROUP BY product_qty_type + + +/* 4. Prove that min is working */ + +SELECT DISTINCT + product_name +,product_qty_type +--,MIN(original_price); +,original_price + +FROM vendor_inventory as vi +INNER JOIN product as p + ON p.product_id = vi.product_id + +ORDER BY product_qty_type, original_price; + + +/* 5. Min/max on a string +... not particularly useful? */ + +SELECT max(product_name) +FROM product; + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* Arithmitic */ + + +/* 1. power, pi(), ceiling, division, integer division, etc */ +SELECT power(4,2), pi(); + +SELECT 10.0 / 3.0 as division, +CAST(10.0 as INT) / CAST(3.0 as INT) as integer_division; + + + +/* 2. Every even vendor_id with modulo */ +SELECT * FROM vendor +WHERE vendor_id % 2 = 0; + + +/* 3. What about every third? */ + +SELECT * FROM vendor +WHERE vendor_id % 3 = 0; + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* HAVING */ + + +/* 1. How much did a customer spend on each day? +Filter to customer_id between 1 and 5 and total_cost > 50 +... What order of execution occurs?*/ + +SELECT +market_date +,customer_id +,SUM(quantity*cost_to_customer_per_qty) as total_spend + +FROM customer_purchases +WHERE customer_id BETWEEN 1 AND 5 +GROUP BY market_date, customer_id +HAVING total_spend > 50; + +/* 2. How many products were bought? +Filter to number of purchases between 300 and 500 */ + +SELECT count(product_id) as num_of_prod +,product_id +FROM customer_purchases +GROUP BY product_id +HAVING count(product_id) BETWEEN 300 AND 500 -- the same as putting &quot;num_of_prod&quot; but not all versions accept + + + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* Subquery FROM */ + + +/*1. Simple subquery in a FROM statement, e.g. for inflation +...we could imagine joining this to a more complex query perhaps */ + + +SELECT DISTINCT +product_id +,inflation + +FROM ( + SELECT product_id, cost_to_customer_per_qty, + CASE WHEN cost_to_customer_per_qty < 1.00 THEN cost_to_customer_per_qty*5 + ELSE cost_to_customer_per_qty END as inflation + + FROM customer_purchases +); + +/* 2. What is the single item that has been bought in the greatest quantity?*/ + + +--outer QUERY +SELECT product_name -- coming from product table +,MAX(quantity_purchased) -- coming from the subquery (&quot;x&quot;) + +FROM product AS p +INNER JOIN ( +--inner query + SELECT product_id + ,count(quantity) as quantity_purchased + + FROM customer_purchases + GROUP BY product_id +) AS x ON p.product_id = x.product_id +/* MODULE 3 */ +/* Subquery WHERE */ + + +/* 1. How much did each customer spend at each vendor for each day at the market WHEN IT RAINS */ + +SELECT market_date +,customer_id +,vendor_id +,SUM(quantity*cost_to_customer_per_qty) as total_spent + +FROM customer_purchases + +-- filter by rain_flag +-- "what dates was it raining?" +WHERE market_date IN +( + SELECT market_date + FROM market_date_info + WHERE market_rain_flag = 1 +) +GROUP BY market_date,vendor_id, customer_id + +/* 2. What is the name of the vendor who sells pie */ + +SELECT DISTINCT vendor_name + +FROM customer_purchases as cp +INNER JOIN vendor as v + ON cp.vendor_id = v.vendor_id + +WHERE product_id IN ( + SELECT product_id + FROM product + WHERE product_name LIKE '%pie%' + ) +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* Temp Tables */ + + +/* 1. Put our inflation query into a temp table, e.g. as temp.new_vendor_inventory*/ + +/* some structural code */ +/* ...heads up, sometimes this query can be finnicky -- it's good to try highlighting different sections to help it succeed...*/ + +-- if a table named new_vendor_inventory exists, delete it, otherwise do NOTHING +DROP TABLE IF EXISTS temp.new_vendor_inventory; + +--make the table +CREATE TABLE temp.new_vendor_inventory AS + +-- definition of the table + +SELECT *, +original_price*5 as inflation +FROM vendor_inventory; + + +/* 2. put the previous table into another temp table, e.g. as temp.new_new_vendor_inventory */ + +DROP TABLE IF EXISTS temp.new_new_vendor_inventory; +CREATE TABLE temp.new_new_vendor_inventory AS + +SELECT * +,inflation * 2 as super_inflation +FROM temp.new_vendor_inventory + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* Common Table Expression (CTE) */ + + +/* 1. Calculate sales per vendor per day */ +SELECT + + + + + +/* ... re-aggregate the daily sales for each WEEK instead now */ + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +/* MODULE 3 */ +/* Date functions */ + + +/* 1. now */ +SELECT + + +/* 2. strftime */ + + + +/* 3. adding dates, e.g. last date of the month */ + + + +/* 4. difference between dates, + a. number of days between now and each market_date + b. number of YEARS between now and market_date + c. number of HOURS bewtween now and market_date + */ +