[Bast-commits] r4580 - in SQL-Abstract/1.x/branches/cleanup: . etc lib/SQL

groditi at dev.catalyst.perl.org groditi at dev.catalyst.perl.org
Wed Jul 16 17:35:54 BST 2008


Author: groditi
Date: 2008-07-16 17:35:53 +0100 (Wed, 16 Jul 2008)
New Revision: 4580

Added:
   SQL-Abstract/1.x/branches/cleanup/etc/
   SQL-Abstract/1.x/branches/cleanup/etc/having-cases.sql
Modified:
   SQL-Abstract/1.x/branches/cleanup/lib/SQL/Abstract2.pm
Log:
adding HAVING cases

Added: SQL-Abstract/1.x/branches/cleanup/etc/having-cases.sql
===================================================================
--- SQL-Abstract/1.x/branches/cleanup/etc/having-cases.sql	                        (rev 0)
+++ SQL-Abstract/1.x/branches/cleanup/etc/having-cases.sql	2008-07-16 16:35:53 UTC (rev 4580)
@@ -0,0 +1,31 @@
+
+-- CASE 1
+SELECT users.name, SUM(commission) AS total 
+  FROM commissions
+    INNER JOIN users ON ( commissions.recipient_id = users.id )
+  WHERE commissions.entry_date > '2007-01-01'
+  GROUP BY commissions.recipient_id
+    HAVING total > 500
+  ORDER BY total DESC;
+
+-- CASE 2
+SELECT users.name, aggregates.total FROM (
+       SELECT recipient_id, SUM(commission) AS total
+       FROM commissions
+       WHERE commissions.entry_date > '2007-01-01'
+       GROUP BY commissions.recipient_id
+       HAVING total > 500
+   ) AS aggregates
+INNER JOIN users ON(aggregates.recipient_id = users.id)
+ORDER BY aggregates.total DESC;
+
+-- CASE 3
+SELECT users.name, aggregates.total FROM (
+       SELECT recipient_id, SUM(commission) AS total
+       FROM commissions
+       WHERE commissions.entry_date > '2007-01-01'
+       GROUP BY commissions.recipient_id
+   ) AS aggregates
+INNER JOIN users ON(aggregates.recipient_id = users.id)
+WHERE aggregates.total > 500
+ORDER BY aggregates.total DESC

Modified: SQL-Abstract/1.x/branches/cleanup/lib/SQL/Abstract2.pm
===================================================================
--- SQL-Abstract/1.x/branches/cleanup/lib/SQL/Abstract2.pm	2008-07-15 22:13:08 UTC (rev 4579)
+++ SQL-Abstract/1.x/branches/cleanup/lib/SQL/Abstract2.pm	2008-07-16 16:35:53 UTC (rev 4580)
@@ -105,7 +105,7 @@
      'where' => {
                  args_min => 1,
                  args_max => 1,
-                 handler => 'handle_op_sql_word_and_args'
+                 handler => 'handle_op_sql_word_and_args',
                 },
     );
 




More information about the Bast-commits mailing list