Skip to content

Assignment one - #1

Open
MagicalBolt wants to merge 4 commits into
mainfrom
assignment-one
Open

MagicalBolt wants to merge 4 commits into
mainfrom
assignment-one

Conversation

@MagicalBolt

@MagicalBolt MagicalBolt commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

What did you learn from the changes you have made?

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

How were these changes tested?

A reference to a related issue in your repository (if applicable)

Checklist

  • I can confirm that my changes are working as intended

@github-actions

Copy link
Copy Markdown

🧪 SQL Queries Run Results (up to 3 rows)

Click to expand/collapse assignment queries execution results

✅ Query 1:

SELECT *
FROM customer
,

Results:

customer_id customer_first_name customer_last_name customer_postal_code
1 Alejandro Costa M8Y
2 Mei Chen M1L
3 Amir Khan M4H

✅ Query 2:

SELECT *
FROM customer
ORDER BY customer_last_name ASC, customer_first_name ASC
LIMIT 10
,

Results:

customer_id customer_first_name customer_last_name customer_postal_code
4 Leyla Abadi M1L
7 Anwar Ali M6C
12 Jalen Carter M1L

✅ Query 3:

SELECT *
FROM customer_purchases
WHERE product_id = 4 OR product_id = 9
LIMIT 25
,

Results:

product_id vendor_id market_date customer_id quantity cost_per_quantity transaction_time
4 7 2022-04-05 3 1 4 18:44:00
4 7 2022-04-05 4 1 4 18:09:00
4 7 2022-04-05 5 3 4 18:54:00

✅ Query 4:

*--One condition using BETWEEN
SELECT ,
ROUND((quantity
cost_per_quantity),2) AS price
FROM customer_purchases
WHERE customer_id BETWEEN 8 AND 10
ORDER BY customer_id;

--Two conditions using AND
SELECT ,
ROUND((quantity
cost_per_quantity),2) AS price
FROM customer_purchases
WHERE customer_id >=8 AND customer_id <= 10
ORDER BY customer_id*,

Results:

product_id vendor_id market_date customer_id quantity cost_per_quantity transaction_time price
1 7 2022-07-12 8 2.71 6.99 18:35:00 18.94
1 7 2022-08-02 8 3.83 6.99 18:34:00 26.77
1 7 2022-08-16 8 3.57 6.99 18:04:00 24.95

✅ Query 5:

SELECT product_id,
product_name,
--product_qty_type,
CASE
WHEN product_qty_type='unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed
FROM product
ORDER BY product_id
,

Results:

product_id product_name prod_qty_type_condensed
1 Habanero Peppers - Organic bulk
2 Jalapeno Peppers - Organic bulk
3 Poblano Peppers - Organic unit

✅ Query 6:

SELECT product_id,
product_name,
--product_qty_type,
CASE
WHEN product_qty_type='unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed,
CASE
WHEN product_name LIKE '%pepper%' THEN 1
ELSE 0
END AS pepper_flag
FROM product
ORDER BY product_id
,

Results:

product_id product_name prod_qty_type_condensed pepper_flag
1 Habanero Peppers - Organic bulk 1
2 Jalapeno Peppers - Organic bulk 1
3 Poblano Peppers - Organic unit 1

✅ Query 7:

SELECT a.,
v.vendor_name,
v.vendor_type,
v.vendor_owner_first_name,
v.vendor_owner_last_name
FROM vendor_booth_assignments a
INNER JOIN vendor v
ON a.vendor_id = v.vendor_id
ORDER BY market_date ASC, vendor_name ASC
LIMIT 24*,

Results:

vendor_id booth_number market_date vendor_name vendor_type vendor_owner_first_name vendor_owner_last_name
8 6 2022-04-05 Annie's Pies Prepared Foods Annie Aquinas
1 2 2022-04-05 Chris's Sustainable Eggs & Meats Eggs & Meats Chris Sylvan
4 7 2022-04-05 Fields of Corn Fresh Focused Samuel Smith

✅ Query 8:

SELECT vendor_id,
count(booth_number) AS times_booths_rented
FROM vendor_booth_assignments
GROUP BY vendor_id
,

Results:

vendor_id times_booths_rented
1 142
3 142
4 211

✅ Query 9:

SELECT cp.customer_id,
c.customer_first_name,
c.customer_last_name,
ROUND(SUM(cp.quantity
cp.cost_per_quantity),2) as total_spend
FROM customer_purchases cp
LEFT JOIN customer c
ON cp.customer_id = c.customer_id
GROUP BY cp.customer_id
HAVING total_spend > 2000
ORDER BY customer_last_name, customer_first_name*,

Results:

customer_id customer_first_name customer_last_name total_spend
4 Leyla Abadi 3561.63
7 Anwar Ali 2921.17
12 Jalen Carter 3290.08

⚪ Query 10:

*DROP TABLE IF EXISTS temp.new_vendor;

CREATE TABLE temp.new_vendor AS
SELECT *
FROM vendor;

INSERT INTO temp.new_vendor
VALUES (10,'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal');

--SELECT * FROM temp.new_vendor*,

No rows returned


✅ Query 11:

SELECT customer_id,
--market_date,
strftime('%m',market_date) AS month,
strftime('%Y',market_date) AS year
FROM customer_purchases
LIMIT 25
,

Results:

customer_id month year
14 07 2022
14 07 2022
15 07 2022

✅ Query 12:

SELECT customer_id,
--market_date,
strftime('%m-%Y',market_date) AS month_year,
ROUND(SUM(quantity
cost_per_quantity),2) as total_spend
FROM customer_purchases
WHERE month_year = '04-2022'
GROUP BY customer_id*,

Results:

customer_id month_year total_spend
1 04-2022 152
2 04-2022 172.5
3 04-2022 152

@github-actions

Copy link
Copy Markdown

🧪 SQL Queries Run Results (up to 3 rows)

Click to expand/collapse assignment queries execution results

✅ Query 1:

SELECT *
FROM customer
,

Results:

customer_id customer_first_name customer_last_name customer_postal_code
1 Alejandro Costa M8Y
2 Mei Chen M1L
3 Amir Khan M4H

✅ Query 2:

SELECT *
FROM customer
ORDER BY customer_last_name ASC, customer_first_name ASC
LIMIT 10
,

Results:

customer_id customer_first_name customer_last_name customer_postal_code
4 Leyla Abadi M1L
7 Anwar Ali M6C
12 Jalen Carter M1L

✅ Query 3:

SELECT *
FROM customer_purchases
WHERE product_id = 4 OR product_id = 9
LIMIT 25
,

Results:

product_id vendor_id market_date customer_id quantity cost_per_quantity transaction_time
4 7 2022-04-05 3 1 4 18:44:00
4 7 2022-04-05 4 1 4 18:09:00
4 7 2022-04-05 5 3 4 18:54:00

✅ Query 4:

*--One condition using BETWEEN
SELECT ,
ROUND((quantity
cost_per_quantity),2) AS price
FROM customer_purchases
WHERE customer_id BETWEEN 8 AND 10
ORDER BY customer_id;

--Two conditions using AND
SELECT ,
ROUND((quantity
cost_per_quantity),2) AS price
FROM customer_purchases
WHERE customer_id >=8 AND customer_id <= 10
ORDER BY customer_id*,

Results:

product_id vendor_id market_date customer_id quantity cost_per_quantity transaction_time price
1 7 2022-07-12 8 2.71 6.99 18:35:00 18.94
1 7 2022-08-02 8 3.83 6.99 18:34:00 26.77
1 7 2022-08-16 8 3.57 6.99 18:04:00 24.95

✅ Query 5:

SELECT product_id,
product_name,
--product_qty_type,
CASE
WHEN product_qty_type='unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed
FROM product
ORDER BY product_id
,

Results:

product_id product_name prod_qty_type_condensed
1 Habanero Peppers - Organic bulk
2 Jalapeno Peppers - Organic bulk
3 Poblano Peppers - Organic unit

✅ Query 6:

SELECT product_id,
product_name,
--product_qty_type,
CASE
WHEN product_qty_type='unit' THEN 'unit'
ELSE 'bulk'
END AS prod_qty_type_condensed,
CASE
WHEN product_name LIKE '%pepper%' THEN 1
ELSE 0
END AS pepper_flag
FROM product
ORDER BY product_id
,

Results:

product_id product_name prod_qty_type_condensed pepper_flag
1 Habanero Peppers - Organic bulk 1
2 Jalapeno Peppers - Organic bulk 1
3 Poblano Peppers - Organic unit 1

✅ Query 7:

SELECT a.,
v.vendor_name,
v.vendor_type,
v.vendor_owner_first_name,
v.vendor_owner_last_name
FROM vendor_booth_assignments a
INNER JOIN vendor v
ON a.vendor_id = v.vendor_id
ORDER BY market_date ASC, vendor_name ASC
LIMIT 24*,

Results:

vendor_id booth_number market_date vendor_name vendor_type vendor_owner_first_name vendor_owner_last_name
8 6 2022-04-05 Annie's Pies Prepared Foods Annie Aquinas
1 2 2022-04-05 Chris's Sustainable Eggs & Meats Eggs & Meats Chris Sylvan
4 7 2022-04-05 Fields of Corn Fresh Focused Samuel Smith

✅ Query 8:

SELECT vendor_id,
count(booth_number) AS times_booths_rented
FROM vendor_booth_assignments
GROUP BY vendor_id
,

Results:

vendor_id times_booths_rented
1 142
3 142
4 211

✅ Query 9:

SELECT cp.customer_id,
c.customer_first_name,
c.customer_last_name,
ROUND(SUM(cp.quantity
cp.cost_per_quantity),2) as total_spend
FROM customer_purchases cp
LEFT JOIN customer c
ON cp.customer_id = c.customer_id
GROUP BY cp.customer_id
HAVING total_spend > 2000
ORDER BY customer_last_name, customer_first_name*,

Results:

customer_id customer_first_name customer_last_name total_spend
4 Leyla Abadi 3561.63
7 Anwar Ali 2921.17
12 Jalen Carter 3290.08

✅ Query 10:

*DROP TABLE IF EXISTS temp.new_vendor;

CREATE TABLE temp.new_vendor AS
SELECT *
FROM vendor;

INSERT INTO temp.new_vendor
VALUES (10,'Thomass Superfood Store', 'Fresh Focused', 'Thomas', 'Rosenthal');

SELECT * FROM temp.new_vendor*,

Results:

vendor_id vendor_name vendor_type vendor_owner_first_name vendor_owner_last_name
1 Chris's Sustainable Eggs & Meats Eggs & Meats Chris Sylvan
2 Hernández Salsa & Veggies Fresh Variety: Veggies & More Maria Hernández
3 Mountain View Vegetables Fresh Variety: Veggies & More Joseph Yoder

✅ Query 11:

SELECT customer_id,
--market_date,
strftime('%m',market_date) AS month,
strftime('%Y',market_date) AS year
FROM customer_purchases
LIMIT 25
,

Results:

customer_id month year
14 07 2022
14 07 2022
15 07 2022

✅ Query 12:

SELECT customer_id,
--market_date,
strftime('%m-%Y',market_date) AS month_year,
ROUND(SUM(quantity
cost_per_quantity),2) as total_spend
FROM customer_purchases
WHERE month_year = '04-2022'
GROUP BY customer_id*,

Results:

customer_id month_year total_spend
1 04-2022 152
2 04-2022 172.5
3 04-2022 152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant