3 SELECT users.name, SUM(commission) AS total
5 INNER JOIN users ON ( commissions.recipient_id = users.id )
6 WHERE commissions.entry_date > '2007-01-01'
7 GROUP BY commissions.recipient_id
12 SELECT users.name, aggregates.total FROM (
13 SELECT recipient_id, SUM(commission) AS total
15 WHERE commissions.entry_date > '2007-01-01'
16 GROUP BY commissions.recipient_id
19 INNER JOIN users ON(aggregates.recipient_id = users.id)
20 ORDER BY aggregates.total DESC;
23 SELECT users.name, aggregates.total FROM (
24 SELECT recipient_id, SUM(commission) AS total
26 WHERE commissions.entry_date > '2007-01-01'
27 GROUP BY commissions.recipient_id
29 INNER JOIN users ON(aggregates.recipient_id = users.id)
30 WHERE aggregates.total > 500
31 ORDER BY aggregates.total DESC