Skip to content

Ece completed SQL assignment-1. - #1

Open
feceozkan wants to merge 2 commits into
mainfrom
assignment-one
Open

feceozkan wants to merge 2 commits into
mainfrom
assignment-one

Conversation

@feceozkan

Copy link
Copy Markdown
Owner

< UofT-DSI | - Assignment <1>-->
I've completed these components: logical model, SQL, and response to the article.

Checklist

  • [yes ] I can confirm that my changes are working as intended

@github-actions

github-actions Bot commented Nov 2, 2026

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, customer_first_name
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 IN (4,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:

SELECT ,
quantity
cost_per_quantity as price
FROM customer_purchases
WHERE customer_id <= 10
AND customer_id >= 8
LIMIT 25
,

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.9429
1 7 2022-07-15 10 2.34 6.99 10:21:00 16.3566
1 7 2022-07-15 10 2.28 6.99 10:29:00 15.937199999999999

✅ 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
,

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,
CASE
WHEN LOWER(product_name) LIKE '%pepper%'
THEN 1
ELSE 0
END AS pepper_flag
FROM product
,

Results:

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

✅ 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
,

Results:

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

✅ Query 8:

SELECT vendor_id,
COUNT(
) AS frequency_rentals
FROM vendor_booth_assignments
GROUP BY vendor_id*,

Results:

vendor_id frequency_rentals
1 142
3 142
4 211

✅ Query 9:

SELECT c.customer_id, c.customer_last_name, c.customer_first_name,
SUM(cp.quantity * cp.cost_per_quantity) AS total_spent
FROM customer AS c
JOIN customer_purchases AS cp
ON c.customer_id = cp.customer_id
GROUP BY c.customer_id, c.customer_last_name, c.customer_first_name
HAVING SUM(cp.quantity * cp.cost_per_quantity) > 2000
ORDER BY c.customer_last_name, c.customer_first_name
,

Results:

customer_id customer_last_name customer_first_name total_spent
4 Abadi Leyla 3561.6286
7 Ali Anwar 2921.1743
12 Carter Jalen 3290.0783

⚪ Query 10:

CREATE TEMP TABLE new_vendor AS
SELECT *
FROM vendor;
INSERT INTO new_vendor
VALUES (10,'Thomass Superfood Store','Fresh Focused','Thomas','Rosenthal')
,

No rows returned


✅ Query 11:

SELECT customer_id,
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,
strftime('%m', market_date) AS month,
strftime('%Y', market_date) AS year
FROM customer_purchases;

SELECT customer_id,
SUM(quantitycost_per_quantity) AS total_spent
FROM customer_purchases
WHERE strftime('%m', market_date) = '04'
AND strftime('%Y', market_date) = '2022'
GROUP BY customer_id
,

Results:

customer_id total_spent
1 152
2 172.5
3 152

@khsergvl khsergvl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Approved!

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.

2 participants