I’m using Symfony Project 1.4 and Postgresql
I got error query in doctrine using
$q = Doctrine_Query::create()
->select("count(sex) as total, sex")
->from('Biodata')
->groupBy('sex')
->execute();
there is always display error like this when debug:
SQLSTATE[42803]: Grouping error: 7 ERROR: column "e.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT e.id AS e__id, e.sex AS e__sex, COUNT(e.sex) AS e__0 ...
^. Failing Query: "SELECT e.id AS e__id, e.sex AS e__sex, COUNT(e.sex) AS e__0 FROM biodata e GROUP BY e.sex"
How to fix it and hide e.id column, is this bugs or need a trick?
Excepted result:

Doctrine automatically add the primary key to the select list. We’ve got the same error using MSSQL.
Try to add not hydrate result:
You won’t have column name, but something like this I think: