SELECT a.id, a.username, a.email, a.created, b.user_id,
SUM( (b.price >500) +100 ) + SUM( b.price ) AS gr, SUM( b.price ) AS pris,
b.created, c.user_id, c.referrer_id, c.created, d.id, d.beginner, d.winner_id
FROM users a, accounts b, referrals c, product d
WHERE a.created
BETWEEN '2013-05-01'
AND '2013-05-31'
AND a.id = b.user_id
AND a.id = c.user_id
AND d.beginner != '1'
AND d.winner_id = a.id
GROUP BY c.referrer_id
ORDER BY `pris` ASC
LIMIT 0 , 3
我已经制定了这个查询。我想解决的问题是
SUM(( b.price >500) +100) + SUM( b.price ) AS gr
我希望它计算得像如果一个 id 的总价在一个月内超过 500 则它加 100一个月超过500?