-
Notifications
You must be signed in to change notification settings - Fork 0
Hw2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
updated homework 2
homework 2 requirements files updated
BitaEt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
submitting
|
|
||
|
|
||
|
|
||
| SELECT bc.batter,bc.Hit, bc.atBat,g.game_id, g.local_date,(SUM(Hit) / SUM(atBat)) AS bAVG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add the year in the select statement as well, to get insight on batting average per batter every year
| ORDER BY bc.batter desc; | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot see the second question (rolling batting average), can you guide me on where to look for it?
|
|
||
| create index idx_batter_counts on baseball.batter_counts(game_id); | ||
| create index idx_game on baseball.game(game_id); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something that I noticed that gives error at least for me, is that when choosing tables you don't select the database. I am not sure what your database is called, but let's imagine if it's baseball, every time you have the query select from it should be from baseball.table, so for example here it should be baseball.batter_counts (it doesn't run for me either way, maybe yours works differently)
| on nb.local_date | ||
| where nb.local_date between nb.local_date -100 and nb.local_date | ||
| GROUP by nb.batter; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this took longer than I expected, I feel like if you use DATE_ADD in your where statement it might be helpful to reduce the query running time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I am not sure what the purpose of the join query was. I didn't see how nb2 was used. and the where statement does not seems logical to me, we need the last 100 days, the way I calculated this for my own assignment was considering a max for local_date and an interval of 100 days before that, and calculate batting average of the batters in the timespan. I am not sure what your logic was but the join query was never used here.
Bita use this one not version hw2v2 that one was a mistake.