D
D
drozanov2017-04-05 20:06:50
Algorithms
drozanov, 2017-04-05 20:06:50

Distribution of bonuses between users?

There are for example 5 users. (There can be as many users as you like)
id - points
1 - 3
2 - 1
3 - 5
4 - 8
5 - 9
For example, the total number of bonuses is 500.
How can I distribute bonuses between all users from higher to lower points?
Who scored more points (points) - more bonuses received.
The users are in the users database.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2017-04-05
@drozanov

Um .... every day, the questions boil down to "How much is 2 + 2?"
What do you need to solve your problem?
1) Total number of bonuses.
2) The number of points scored by users. Taken by the following query:
"select sum(points) from users where 1;"
3) Calculate the number of bonuses for all users or a specific one, followed by a query, where :bal is the total number of points scored by users:
"select id, 500/100* ( points/:points) as bonus from users where 1"
Is it so difficult think for yourself, honestly?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question