Skip to content

Homework -HW 1, 2, 3#3

Open
NabZaf wants to merge 5 commits intoHomework1from
Homework
Open

Homework -HW 1, 2, 3#3
NabZaf wants to merge 5 commits intoHomework1from
Homework

Conversation

@NabZaf
Copy link
Copy Markdown
Owner

@NabZaf NabZaf commented May 19, 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
Copy Markdown

@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, Hw3 : Both look good 10/10!

Copy link
Copy Markdown

@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: 7/8
correct answer:
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

Copy link
Copy Markdown

@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: 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