Skip to content

Assignment one - #1

Open
BeinClaveria wants to merge 3 commits into
mainfrom
assignment-one
Open

BeinClaveria wants to merge 3 commits into
mainfrom
assignment-one

Conversation

@BeinClaveria

Copy link
Copy Markdown
Owner

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

I was creating an SQL code that would show a customized version of an existing data for analysis

What did you learn from the changes you have made?

That positioning of the tables, connecting tables and minor changes can make a big difference on how the data will be shown in the output.

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

In some of the code I was sure that I needed to use ORDER BY instead of GROUP BY but when I tried it, it did not show the data the way I wanted so needed to update.

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

It's just creating the code itself. I needed to create the basis first, SELECT and FROM. Then add code base on needs, like on SELECT I would then specify further which table to show instead of all. I would also then add filters like ORDER BY, GROUP BY and HAVING. Then connecting one table to another. It feels like building a house and you would go back and forth. Correcting and changing until the code is fully built.

How were these changes tested?

I tested by running the code on SQLite. For most part I don't get it right away so I correct and edit up until it shows the data the way I wanted it to show.

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

I mainly answered directly on GitHub this time unlike on python class so when I wanted to push I realized the branch already exist on GitHub. So for the diagram I just added file and did commit directly.

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, 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 customer_id = '4' OR customer_id='9'
LIMIT 25
,

Results:

product_id vendor_id market_date customer_id quantity cost_per_quantity transaction_time
1 7 2022-07-08 4 0.27 6.99 12:20:00
1 7 2022-07-12 4 2.13 6.99 18:06:00
1 7 2022-07-19 4 3.03 6.99 18:44:00

✅ Query 4:

*SELECT , quantity * cost_per_quantity AS 'Price'
FROM customer_purchases
WHERE customer_id BETWEEN 8 and 10
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 product_qty_type_condensed
FROM product
,

Results:

product_id product_name product_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 product_qty_type = 'unit' THEN 'Unit'
ELSE 'Bulk'
END AS product_qty_type_condensed,
CASE
WHEN product_name LIKE '%PEPPER%' THEN '1'
ELSE '0'
END AS 'Pepper_Flag'
FROM product
,

Results:

product_id product_name product_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 *
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:

**,

No rows returned


⚪ Query 9:

**,

No rows returned


⚪ Query 10:

**,

No rows returned


⚪ Query 11:

**,

No rows returned


⚪ Query 12:

**,

No rows returned


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