I've got the following SQL tables
Department
|name|employees|
Employee
|name|gender|type|dead |
|John|male |good|yes |
|Mary|female|bad |no |
|Joe |male |ugly|maybe|
I would like to write a statement that returns
| type | n of employees | n of male employees | n of departments |
I've got
SELECT e.type, count(e), count(d)
FROM Department d
JOIN d.employees e
WHERE e.dead = maybe
GROUP BY e.type
That's missing the 'n of male employees', of course. I'm stuck here, since I'm not sure, where to specify the additional clause e.gender = male.
I forgot to mention: HQL or criteria would be nice.