From 6b2a5bcc504ed1a799008577bf961acae6691992 Mon Sep 17 00:00:00 2001 From: Samira Dib Date: Sun, 3 May 2026 19:45:26 -0400 Subject: [PATCH 1/2] Complete assignment 1 SQL queries --- .../assignment1_section2.sql | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 02_activities/assignments/Microcredential_Cohort/assignment1_section2.sql diff --git a/02_activities/assignments/Microcredential_Cohort/assignment1_section2.sql b/02_activities/assignments/Microcredential_Cohort/assignment1_section2.sql new file mode 100644 index 000000000..828136889 --- /dev/null +++ b/02_activities/assignments/Microcredential_Cohort/assignment1_section2.sql @@ -0,0 +1,98 @@ +SELECT * +FROM customer; + + +SELECT * +FROM customer +ORDER BY customer_last_name, customer_first_name +LIMIT 10; + + +SELECT * +FROM customer_purchases +WHERE product_id IN (4, 9) +LIMIT 25; + + +SELECT *, + quantity * cost_to_customer_per_qty as price +FROM customer_purchases +WHERE customer_id BETWEEN 8 AND 10 +LIMIT 25; + + +SELECT product_id, + product_name, + CASE + WHEN product_qty_type = 'unit' THEN 'unit' + ELSE 'bulk' + END AS prod_qty_type_condensed +FROM product; + + +SELECT product_id, + product_name, + CASE + WHEN product_qty_type = 'unit' then 'unit' + ELSE 'bulk' + END as product_qty_type_condensed, + CASE + WHEN lower(product_name) like '%pepper%' THEN 1 + ELSE 0 + END as pepper_flag + FROM product; + +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; + + +SELECT vendor_id, + count(*) as booth_rental_count +FROM vendor_booth_assignments +GROUP by vendor_id; + + +SELECT c.customer_id, + c.customer_first_name, + c.customer_last_name, + SUM(cp.quantity * cp.cost_to_customer_per_qty) AS total_spent +FROM customer c +INNER JOIN customer_purchases cp + ON c.customer_id = cp.customer_id +GROUP BY c.customer_id, + c.customer_first_name, + c.customer_last_name +HAVING SUM(cp.quantity * cp.cost_to_customer_per_qty) > 2000 +ORDER BY c.customer_last_name, + c.customer_first_name; + + +CREATE TEMP TABLE new_vendor AS +SELECT * +FROM vendor; + +INSERT INTO new_vendor +(vendor_id, vendor_name, vendor_type, vendor_owner_first_name, vendor_owner_last_name) +VALUES +(10, 'Samira superfood Store', 'Fresh Focused Store', 'Samira', 'Dib'); + + +SELECT +customer_id, + strftime ('%m', market_date) as month, + strftime('%Y', market_date) as year +FROM customer_purchases +LIMIT 25; + + +SELECT +customer_id, + sum(quantity * cost_to_customer_per_qty) as total_spent +FROM customer_purchases +WHERE strftime('%m', market_date) = '04' + AND strftime('%Y', market_date) = '2022' +group by customer_id From 2f0b542f3f89dfe0e5be0b2338431d1532184580 Mon Sep 17 00:00:00 2001 From: Samira Dib Date: Mon, 11 May 2026 19:26:15 -0400 Subject: [PATCH 2/2] Completed assignment2.sql --- 50 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 50 diff --git a/50 b/50 new file mode 100644 index 000000000..e69de29bb