There is way to drop the dummy aggregate function in group by - http://blog.jooq.org/2015/12/10/sql-group-by-and-functional-dependencies-a-very-useful-feature/