Problem history:

The query works prior to [430bb59d798286a] on 2012-04-17 in between versions 3.7.11 and 3.7.12.  In release version 3.7.12, 2012-05-14, the script
causes a segfault in the query planner.  The query planner segfault is
recorded by ticket [c2ad16f997ee9c8] and is fixed by check-in
[e459c3360ba2543].  After this fix, the query reported by this ticket
returns "misuse of aggregate: sum()".  That was the result as of
version 3.7.13.  The current problem (a segfault in the VM while running
the query) originates with check-in [d4cd6017c987594] on 2012-08-24, in
between version 3.7.13 and 3.7.14.