Skip to content

Conversation

@TDerig23
Copy link
Owner

Bita use this one not version hw2v2 that one was a mistake.

Copy link
Collaborator

@BitaEt BitaEt left a 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
Copy link
Collaborator

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;



Copy link
Collaborator

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);

Copy link
Collaborator

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;

Copy link
Collaborator

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.

Copy link
Collaborator

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.

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