From: Matt S Trout Date: Wed, 16 Jul 2008 18:56:05 +0000 (+0000) Subject: more examples X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=252475d885f7ec90e1d15368233f8269ae68ad82;p=dbsrgits%2FSQL-Abstract.git more examples --- diff --git a/e.pl b/e.pl index 60c2414..24ee949 100644 --- a/e.pl +++ b/e.pl @@ -92,3 +92,35 @@ warn dump( } ] ); + +warn dump( + ORDER_BY { $_->aggregates->total } + SELECT { $_->users->name, $_->aggregates->total } + JOIN { $_->users->id == $_->aggregates->recipient_id } + [ users => expr { $_->users } ], + [ aggregates => + expr { + SELECT { $_->recipient_id, [ total => sum($_->commission) ] } + WHERE { sum($_->commission) > 500 } + GROUP_BY { $_->recipient_id } + WHERE { $_->entry_date > '2007-01-01' } + expr { $_->commissions } + } + ] +); + +warn dump( + ORDER_BY { $_->aggregates->total } + SELECT { $_->users->name, $_->aggregates->total } + WHERE { $_->aggregates->total > 500 } + JOIN { $_->users->id == $_->aggregates->recipient_id } + [ users => expr { $_->users } ], + [ aggregates => + expr { + SELECT { $_->recipient_id, [ total => sum($_->commission) ] } + GROUP_BY { $_->recipient_id } + WHERE { $_->entry_date > '2007-01-01' } + expr { $_->commissions } + } + ] +);