Jaskowaty Jaskowaty - 2 years ago 106
SQL Question

How to SUM multiple distinct values and get max value in SQL

I'm a using distinct select in the Oracle SQL, what I want to do is sum up all the data at specific ID. Example in image:

The ouput of query now

So for example where PlayerIDFK is 1 I want to sum up TwoPointsMade in one column and ThrePointsMade in another, so for that the result would be

PlayerIDFK TwoPointsMade ThreePointsMade
1 5 2

The query Im using now is:

SELECT PlayerIDFK, TwoPointMade, ThreePointMade
FROM PlayerPerformance
FROM PlayerPerformance);

Answer Source

I think you could use the groupby-clause where you could group by playerIDFK and sum over twopointsmade and threepointsmade

Something like this might work:

SELECT PlayerIDFK, sum(TwoPointMade), sum(ThreePointMade) FROM PlayerPerformance GROUP BY PlayerIDFK
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download