What I want to do is count the number of rows returned by a subquery, essentially the following:
select pp.prop_id, COUNT((select employee_id from employee e where e.ao1_hours > 0))
from proposal_piece pp
group by pp.prop_id
order by pp.prop_id
Here is my error message:
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
Why does this not work? If select is just returning a bunch of employee_id's
with a filtering criteria why can't I count the number of rows or employee_id's
that are being returned?
I am looking to count the number of distinct employees that have ao1_hours > 0
. Grouped by the prop
.
Here is some structural information about my database, as part of a query.
from proposal_piece pp
INNER JOIN employee e
on pp.employee_id = e.employee_id
Thanks!
Try this
or this