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
11 order_by { $_->total }
12 select { $_->users->name, [ total => sum($_->aggregates->commission) ] }
13 where { sum($_->aggregates->commission) > 500 }
14 group_by { $_->commissions->recipient_id }
15 join { $_->users->id == $_->commissions->recipient_id }
16 [ users => expr { $_->users } ],
17 [ commission => expr { $_->commissions } ];
19 my $total = [ -sum => [ -name => 'commission' ] ];
25 [ -name => qw(users name) ],
29 [ '>', $total, [ -value, 500 ] ],
32 [ -name, qw(commissions recipient_id) ],
35 [ '>', [ -name, qw(commissions entry_date) ], [ -value, '2007-01-01' ] ],
46 SELECT users.name, aggregates.total FROM (
47 SELECT recipient_id, SUM(commission) AS total
49 WHERE commissions.entry_date > '2007-01-01'
50 GROUP BY commissions.recipient_id
53 INNER JOIN users ON(aggregates.recipient_id = users.id)
54 ORDER BY aggregates.total DESC;
56 order_by { $_->aggregates->total }
57 select { $_->users->name, $_->aggregates->total }
58 join { $_->users->id == $_->aggregates->recipient_id }
59 [ users => expr { $_->users } ],
62 select { $_->recipient_id, [ total => sum($_->commission) ] }
63 where { sum($_->commission) > 500 }
64 group_by { $_->recipient_id }
65 where { $_->entry_date > '2007-01-01' }
66 expr { $_->commissions }
72 SELECT users.name, aggregates.total FROM (
73 SELECT recipient_id, SUM(commission) AS total
75 WHERE commissions.entry_date > '2007-01-01'
76 GROUP BY commissions.recipient_id
78 INNER JOIN users ON(aggregates.recipient_id = users.id)
79 WHERE aggregates.total > 500
80 ORDER BY aggregates.total DESC
83 order_by { $_->aggregates->total }
84 select { $_->users->name, $_->aggregates->total }
85 where { $_->aggregates->total > 500 }
86 join { $_->users->id == $_->aggregates->recipient_id }
87 [ users => expr { $_->users } ],
90 select { $_->recipient_id, [ total => sum($_->commission) ] }
91 group_by { $_->recipient_id }
92 where { $_->entry_date > '2007-01-01' }
93 expr { $_->commissions }