Skip to content

Assignment two#2

Open
hamedabangar wants to merge 5 commits intomainfrom
assignment-two
Open

Assignment two#2
hamedabangar wants to merge 5 commits intomainfrom
assignment-two

Conversation

@hamedabangar
Copy link
Owner

@hamedabangar hamedabangar commented Aug 15, 2025

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

delivering assignment two

What did you learn from the changes you have made?

building logical model and SQL

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

no

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

no challenges

How were these changes tested?

by running those SQL commands in SQLite

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

not applicable

Checklist

  • I can confirm that my changes are working as intended

Copy link

@monzchan monzchan left a comment

Choose a reason for hiding this comment

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

Please review the comments



SELECT
customer_id, market_date, DENSE_RANK() OVER ( PARTITION BY customer_id ORDER BY market_date ) AS visit_number FROM ( SELECT DISTINCT customer_id, market_date FROM customer_purchases

Choose a reason for hiding this comment

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

Using DISTINCT here reduces multiple purchases on the same day. Usually, for a COUNT window function, you shouldn’t use DISTINCT, because it alters the window calculation.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thanks for the comment. Changed it

select vendor_name,product_name,sum(original_price*5*customer_count) total_revenue from
(
select distinct v.vendor_name,p.product_name,original_price from vendor v
cross join vendor_inventory vi on v.vendor_id = vi.vendor_id

Choose a reason for hiding this comment

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

This might not be a valid syntax. CROSS JOIN doesn't have an ON/
Use JOIN for vendor to inventory, then cross join customer count

Copy link
Owner Author

Choose a reason for hiding this comment

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

this happened by mistake and I fixed it

@hamedabangar
Copy link
Owner Author

New commit has been pushed

Copy link

@monzchan monzchan left a comment

Choose a reason for hiding this comment

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

Good work!!

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