Did you weere able to do a work around?
On Tuesday, September 6, 2011 4:10:56 PM UTC-3, gabrielr wrote:
>
> Hi everybody.
>
> I Have a problem making a GROUP BY operation with PostgreSQL Database.
>
> This is my Code
> <code>
> $apoyosEstado = $this->EncApoyo->find('all',array(
>
> 'fields'=>array('MAX(Estado.estado_id) AS
> edo_id','MAX(Estado.descripcion) AS
> estado','COUNT(EncApoyo.enc_apoyo_id) AS total'),
> 'group'=>
> array('Estado.estado_id')
> ));
> </code>
> And It return an ERROR because Cake Adds the primary key to the SQL
> QUERY. some like this:
>
> SELECT MAX("Estado"."estado_id") AS edo_id,
> MAX("Estado"."descripcion") AS estado,
> COUNT("EncApoyo"."enc_apoyo_id") AS total, "EncApoyo"."enc_apoyo_id"
> AS "EncApoyo__enc_apoyo_id" FROM "enc_apoyos" AS "EncApoyo" LEFT JOIN
> "estados" AS "Estado" ON ("EncApoyo"."estado_id" =
> "Estado"."estado_id") WHERE 1 = 1 GROUP BY "Estado"."estado_id"
>
> This is an error because in PostgreSQL fields to display in a GROUP BY
> query must be contained in an aggregate function.
>
> If someone knows who solve it, answer me please.
>
> Thanks.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php