Skip to content

Commit homework 1 submission#1

Open
JesJH wants to merge 7 commits intomainfrom
homework
Open

Commit homework 1 submission#1
JesJH wants to merge 7 commits intomainfrom
homework

Conversation

@JesJH
Copy link
Copy Markdown
Owner

@JesJH JesJH commented May 15, 2024

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

Adding my homework 1

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 and 6 graded, 10/10 for both!

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 6 6/8:

insert question- missing 'unit' condition
correct answer for Alter question:
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);

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