Forum OpenACS Q&A: Response to aggregate function calls may not be nested

Collapse
Posted by Dan Wickstrom on
If you have pg 7.1, try using a subselect in from:


  select total as n_introduced, 
         sum(total) as total, 
         sum(passed) as passed,
         sum(passed)::float / sum(total) as percent
    from (select r.id as rep_id, 
                 count(*) as total, 
                 sum(passed) as passed
            from reps r, bills b
           where b.rep_id = r.id
        group by r.id) bill_count_v
group by total;