SQL Query question
Hi,
I'm not that familiar with sql. Here's my situation. I'm running mysql, and I have a table of every Batter from the 2003 Baseball season. Each record contains playerID, teamID, games, hits etc. The problem is that some players were traded in midseason last year so there are 2 records for those players, one for their stats from team 1 and one from their stats from team 2. Is there a way in SQL to combine two records? All the fields I need to combine would be small integers. Alternatively I could combine them after extracting them from the database, but I was just wondering if I could do it through SQL. Thanks for any help. |
You mean the playerID is different even though it's the same player on a different team?
Lyle |
No I mean the following:
Code:
So the player is the same, and the playerID is the same but there are 2 different entries one for each team. So I want something like the following: sanchal03 | DET | 144 | 160 | 52 | |
Oh, okay. Hopefully this will help:
Code:
SELECT playerID, SUM(G), SUM(H), SUM(SB) |
Thanks for your help, but I'm getting the following error:
Code:
mysql> SELECT playerID, SUM(G), SUM(H), SUM(SB) FROM Batting WHERE playerID='sanchal03'; I'm not sure if this will help, but here is how the Table is setup: Code:
mysql> DESCRIBE Batting; |
I think that should be
Code:
SELECT playerID, SUM(G), SUM(H), SUM(SB) |
That works great! Thank you both for helping me out.
|
No problem, anytime.
|
All times are GMT -5. The time now is 03:04 PM. |