Skip to content

Assignment two#2

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

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

Conversation

@annlisver
Copy link
Copy Markdown
Owner

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

  • submit assignment 2

What did you learn from the changes you have made?

  • sql coding (update, insert, delete, cross join)

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

  • na

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

  • na

How were these changes tested?

  • I run code in sqlite

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

  • na

Checklist

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

Copy link
Copy Markdown

@efantinatti efantinatti left a comment

Choose a reason for hiding this comment

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

Dear Anna Veremchuk

Session 1:
1 - Partial. Almost good. Check the date table connection requirements to what is asked in the question.

Session 2:
2 - Partial.
-- Windowed Functions - Q3: Query is not correct. You can think in a simpler approach with COUNT() and Partition.

Session 3:
3 - Partial.
-- DELETE - Q1: The WHERE clause condition is hardcoded. Think of a solution that it might process it without hardcoding a value. HINT. Think of minimal values,. Which function could find the minal value?

Final:
4 - Check the aforementioned poins prior merging your feature branch 'assignment-two' to 'main'.

Mark: 50 points.

@annlisver
Copy link
Copy Markdown
Owner Author

annlisver commented Dec 30, 2024

Dear Ernani Fantinatti @efantinatti ,

Thank you for checking and your comments!

"1 - Partial. Almost good. Check the date table connection requirements to what is asked in the question."

Could you please add more details why points were reduced for this ?

The only thing that I found in task text in regard to date table connection is the following:
Additionally, include a date table.
Date table was included under name calendar_date. I also specified possible connection of this table with other tables in the commentary above the table. Have you expected something else here ?

"2 - Partial.
-- Windowed Functions - Q3: Query is not correct. You can think in a simpler approach with COUNT() and Partition."

Could you please specify why this query is not correct?

Task: /* 3. Using a COUNT() window function, include a value along with each row of the
customer_purchases table that indicates how many different times that customer has purchased that product_id. */

Query in submission:
select *
, count() over (partition by customer_id, product_id order by customer_id, product_id) as total_times_product_id_purchased_by_customer
, count() over (partition by customer_id, product_id, market_date order by customer_id, product_id, market_date) as total_times_product_id_purchased_by_customer_during_visit
from customer_purchases

Field total_times_product_id_purchased_by_customer shows number of times product was purchased by customer for every row in customer_purchases table. I have manually checked on two customers and two products and quantities are correct, but it is possible that I am missing something...

"Session 3:
3 - Partial.
-- DELETE - Q1: The WHERE clause condition is hardcoded. Think of a solution that it might process it without hardcoding a value. HINT. Think of minimal values,. Which function could find the minal value?"

Thank you for the hint, it should be fixed now:
delete from temp.product_units
where 1=1
and product_name = 'Apple Pie'
and snapshot_timestamp = (select min(snapshot_timestamp)
from temp.product_units )

BR,
Anna

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