I am having problem in calculating the referral payout for a free bitcoin site. The table structure is as follows..
addr, bal, ref, pending, paid, ref_payment, earning
select * from table where pending > 0 and ref != 'none'
select DISTINCT ref from table where pending > 0 and ref != 'none'
For your first question, I'd suggest something like this (depending on your schema)..
SELECT referrer, FORMAT(SUM(referral_amount),2) total FROM TableName GROUP BY referrer ORDER BY SUM(referral_amount) DESC;
The second one is a simple UPDATE query..
UPDATE table SET column = (SELECT other_column) // maybe with a WHERE