more examples
Matt S Trout [Wed, 16 Jul 2008 18:56:05 +0000 (18:56 +0000)]
e.pl

diff --git a/e.pl b/e.pl
index 60c2414..24ee949 100644 (file)
--- 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 }
+            }
+        ]
+);