Open
Conversation
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.
monzchan
approved these changes
Nov 28, 2025
| ) AS visit_number | ||
| FROM customer_purchases | ||
| ORDER BY customer_id, market_date DESC; | ||
|
|
There was a problem hiding this comment.
consider adding WHERE visit_number = 1 to meet the question requirement
|
|
||
| DELETE FROM product_units | ||
| WHERE product_name = 'Apple Pie'; | ||
|
|
There was a problem hiding this comment.
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);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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