Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mfindlay
Starting Member
5 Posts |
Posted - 2008-04-08 : 21:27:11
|
| Hello,I have 2 tables I am using as test, and for the life of me I can't figure this out.Table: statsColumns: ID, Name, Goals, Assists, PointsExample: 1, George, 1, 1, 2Table: PlayersColumns: ID, Name, Pick1, Pick2, Pick3Example: 1, Bob, 1, 4, 7I want to find the SUM value of stat.Points, where Players.Pick1 = stats.ID for all picks.Then Grouping them by Players.nameAm I creating the database schema wrong for this? |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2008-04-08 : 22:13:32
|
| select b.name, sum(a.points)from stats ajoin players b on a.id = b.pick1group by b.name |
 |
|
|
mfindlay
Starting Member
5 Posts |
Posted - 2008-04-09 : 14:06:01
|
| Thank you so much! I added:join players b on a.id = b.pick1 or a.id = b.pick2 or a.id = b.pick3etc... for all the picks. Much appreciated! |
 |
|
|
|
|
|
|
|