Benji
Benji

Reputation: 23

Math in MYSQL/PHP

I'm a complete novice but I really need to get this done as soon as possible so any help would be greatly appreciated.

I have a table with the following fields: userid, upvoteds , downvoteds, aposts and aselecteds

Basically I need to run this formula for every row:

(upvoteds - downvoteds) / (aposts - aselecteds) Apologies if that formula isn't structured properly.

I need the results presented in desc order along with userid so I know who it belongs to.

Thanks in advance!

Upvotes: 1

Views: 665

Answers (1)

Nicola Cossu
Nicola Cossu

Reputation: 56397

select userid,
(upvoteds - downvoteds) / (aposts - aselecteds) as result
from table    
order by result desc

Upvotes: 8

Related Questions