Conversation
anjali-deshpande-hub
left a comment
There was a problem hiding this comment.
Well done so far. Could you also please add answer to Section 4 in the .md file?
|
|
||
|
|
||
|
|
||
| SELECT DISTINCT -- unique values |
There was a problem hiding this comment.
DISTINCT is not required. The requirement is to filter before April 29, 2022. The WHERE clause should be market_date < '2022-04-29'
|
|
||
| --subquery | ||
| FROM ( | ||
| SELECT DISTINCT |
There was a problem hiding this comment.
DISTINCT is not required here.
|
|
||
| FROM customer_purchases | ||
|
|
||
| WHERE market_date > '2022-04-29' --adding date filter |
There was a problem hiding this comment.
Looks good except the filter should be '<'
|
|
||
| DELETE FROM product_units | ||
| --SELECT * FROM product_expanded -- can help you determine you are looking at the right rows before running a deletion | ||
| WHERE product_id = 100 ; |
There was a problem hiding this comment.
Your query correctly filters by product and uses a timestamp condition. The requirement is to delete the older record for the whatever product you added. You can find the oldest record (e.g., using MIN(snapshot_timestamp)) and delete only that row.
| UPDATE product_units | ||
| SET current_quantity = COALESCE( | ||
|
|
||
| (SELECT quantity |
There was a problem hiding this comment.
This gives syntax error because you cannot give a subquery inside COALESCE() function. The inner subquery can return multiple rows. You are also missing comma before 0 in the COALESCE call.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
adding assignment 2
What did you learn from the changes you have made?
that I keep accidentally clicking Yes to All when the SQL save pop-up comes up and overwriting my entire file. So now I save a backup in a word doc as I go
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
maybe row_number for the window function question
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
lots of syntax issues, and second guessing myself so there's a lot of work-checking included/commented out
How were these changes tested?
running extra code and then commenting it out
A reference to a related issue in your repository (if applicable)
Checklist