A correction, I said it returns all the sales, that is not true, I get
the following error:
"SQL Error: Column 'monthly_sales.product_id' is invalid in the select
list because it is not contained in either an aggregate function or
the GROUP BY clause."
I am using mssql, does it have something to do with it?
On Aug 29, 2:59 pm, bitkidoku <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I am having problems executing a GROUP BY query. Let's say I have
> 'sales' table containing 'id', 'product_id' and 'revenue'. I am
> trying to find total revenue of a different products. So far I did:
>
> $sales = $this->Sale->find( 'all', array(
> 'fields' => array('Sale.product_id', 'SUM(Sale.revenue) as
> total'),
> 'group' => 'Sale.product_id'
> )
> );
>
> It does not work. It returns all of the sales. And I dont see any
> 'GROUP BY' clause in the query debug information.
>
> Any help is appreciated. Thank you for your answers.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---