Need support with a MS SQL select-query

Dear SQL Expers,

I have two tables
ID (int)
Name (varchar)


ID  Name
--  ----
1   Tom
2   Mike

Open in new window

DayNo (int)
PlayerID (int)
GameNo (int)
Score (int)


DayNo  PlayerID  GameNo  Score
-----  --------  ------  -----
1      1         1       100
1      1         2       110
1      2         1       200
1      2         2       210
2      1         1       150
2      1         2       160
2      2         1       250
2      2         2       260

Open in new window

The GameResults table contains scores of idivudal games per player and day. In the above example, two players have each played on two days and on each day have played 2 games. A "game-series" consists of sum of the games each player per day, i.e. Tom has played a series of 210 on day 1 and a series of 310 on day 2, and Mike as played a series of 410 on day 1 and a series of 510 on day 2.

Now I need a query that gives me the highest and lowest series per player, e.g.
Player  SeriesHigh  SeriesLow
------  ----------  ---------
Tom     310         210
Mike    510         410

Open in new window

How would a Select-Query look like to achieve that result?

Thank you VERY much for enlightening me here...

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
select p.Name, min(g.GameNo), max(g.GameNo)
from Players p
left join GameResults g on = g.PlayerID
group by p.Name

Open in new window

I opted for a LEFT JOIN so that it would list all players even if they have not played. If you do not need or want that then use INNER JOIN instead.
StaudteAuthor Commented:
Thanks, Paul, for the quick reply.

But as far as I see this gives my only the highest or lowest game - I need the highest or lowest series, i.e. sum of games of a day.
Scott PletcherSenior DBACommented:
SELECT PlayerID, MAX(Total_Day_Score) AS SeriesHigh, MIN(Total_Day_Score) AS SeriesLow
    SELECT PlayerID, DayNo, SUM(Score) AS Total_Day_Score
    FROM GameResults
    GROUP BY PlayerID, DayNo
) AS derived

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StaudteAuthor Commented:
PERFECT! Thank you so much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.