Skip to content

Assignment two#2

Open
azadeh-selahvarzi wants to merge 11 commits intomainfrom
assignment-two
Open

Assignment two#2
azadeh-selahvarzi wants to merge 11 commits intomainfrom
assignment-two

Conversation

@azadeh-selahvarzi
Copy link
Owner

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

I updated SQL queries and table structures to implement joins, window functions, temporary tables.

What did you learn from the changes you have made?

I learned how different SQL concepts (like window functions, CROSS JOINs, CTEs, INSERT/UPDATE/DELETE logic, and COALESCE) work together to transform and manage data accurately.

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

Yes, I considered using CTEs and DISTINCT filtering in alternative ways to simplify some of the queries and avoid duplicated rows.

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

I faced challenges with duplicated vendor–product rows and correlated subqueries, and I overcame them by isolating the correct source data using DISTINCT and ordering logic

How were these changes tested?

I tested each change by running the queries directly in the SQLite environment and verifying that the output matched the expected logic and row counts.

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

Checklist

  • [ x ] I can confirm that my changes are working as intended

Add a SELECT statement to concatenate product details.
Added SQL queries to rank customer visits and count purchases.
Add SQL query to extract product descriptions from product_name
Refactor SQL query to handle product names with multiple dashes.
Add a query to filter products by size containing numbers.
Added SQL queries to calculate total revenue, create a product_units table, insert a new product, and prepare for deletion and update operations.
Refactor SQL query to calculate total revenue per product using a CTE for vendor products.
Add current_quantity column and update it from vendor_inventory.
Removed original_price from insert statement and added delete statement for older records.
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.

Great work!

) AS visit_number
FROM customer_purchases
ORDER BY customer_id, market_date DESC;

Choose a reason for hiding this comment

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

consider adding WHERE visit_number = 1 to meet the question requirement


DELETE FROM product_units
WHERE product_name = 'Apple Pie';

Choose a reason for hiding this comment

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

This deleted every Apple Pie row, but requirement is to delete only the older timestamp. DELETE FROM product_units
WHERE product_id = 24
AND snapshot_timestamp = (SELECT snapshot_timestamp FROM older_record);

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