December 15th, 2012, 12:08 AM
Not contained in either an aggregate function or the GROUP BY
i am trying sum all the price base on referenceNo, but i get the following error;
Column 'buyerName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
my sql statment
select buyerName, id, category, productName, Sum(price) as "price", date, referenceNo from elena where referenceNo='d11';
Could anyone help ? Thanks
Last edited by xbl1; December 15th, 2012 at 12:26 AM.
December 15th, 2012, 06:11 AM
to understand this error message, follow along with this logic --
1. the SELECT clause contains an aggregate function, SUM(price)
2. the SELECT clause also contains several non-aggregate columns (six of them)
3. these other six columns must therefore also be in the GROUP BY clause but this is actually missing
does the error message make sense now?
put all six of the non-aggregate columns into the GROUP BY clause
December 15th, 2012, 04:27 PM
Thanks a lot, i fix the problem already