Skip to content

Homework 1-6 (attempt 2)#2

Open
Jaay-0 wants to merge 8 commits intomainfrom
homework_1
Open

Homework 1-6 (attempt 2)#2
Jaay-0 wants to merge 8 commits intomainfrom
homework_1

Conversation

@Jaay-0
Copy link
Owner

@Jaay-0 Jaay-0 commented May 31, 2024

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

Copy link

@ananyajha2000 ananyajha2000 left a comment

Choose a reason for hiding this comment

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

Hw 1 graded 8/8!

Copy link

@ananyajha2000 ananyajha2000 left a comment

Choose a reason for hiding this comment

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

HW2 :88
Hw3 : 8/8

Copy link

@ananyajha2000 ananyajha2000 left a comment

Choose a reason for hiding this comment

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

Hw 4: 7/8
correct answer to windowed functions:
SELECT customer_id, market_date,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY market_date) AS visit_number

FROM customer_purchases

GROUP BY customer_id, market_date

Copy link

@ananyajha2000 ananyajha2000 left a comment

Choose a reason for hiding this comment

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

HW 5 6/8:
correct answer to update:
ALTER TABLE product_units
ADD current_quantity INT;

UPDATE product_units
SET current_quantity = (
SELECT current_quantity
FROM (
SELECT p.product_id, COALESCE(quantity,0) as current_quantity

	FROM product_units p
	LEFT JOIN (
		SELECT *
		,ROW_NUMBER() OVER( PARTITION BY vi.product_id ORDER BY market_date DESC) AS rn
		FROM vendor_inventory vi 
	) vi ON p.product_id  = vi.product_id

	WHERE rn = 1 
	OR rn IS NULL
) p

WHERE product_units.product_id = p.product_id);

HW 6: 8/8!

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