sum top 5 question
I have a question about the sum of the top 5 scores.
the code below works but sums all scores and i need only the top 5 scores.
and the selections needs to be year 2016.
i cant figure it out please need some help
erik
Table looks like this:
scores
scid
lidnr
score
dicipline
date
i got this code:
SELECT r.lidnr AS lidnr,
(SELECT Sum(r2.score) FROM scores r2
WHERE r2.lidnr = r.lidnr ORDER BY r2.score DESC LIMIT 5) AS sub,
r.dicipline AS dicipline,
r.score AS score
FROM scores r
GROUP BY r.lidnr,
r.dicipline,
r.score,
(SELECT Sum(r2.score) FROM scores r2 WHERE r2.lidnr = r.lidnr LIMIT 5)
ORDER BY (SELECT Sum(r2.score) FROM scores r2
WHERE r2.lidnr = r.lidnr LIMIT 5) DESC,
dicipline DESC
Subject
Written By
Posted
sum top 5 question
April 28, 2016 04:34AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.