在选择查询将其放置在GROUP BY截至见下表总结现场没有SQL
id invoice_id item_id cost price quantity
1 1 1 32.00 35.00 5
2 2 1 32.00 35.00 6
3 4 2 43.00 52.00 8
所示我想组它通过它的ITEM_ID,成本,价格,而总结的数量
我已经试过这
select item_id, cost,price, sum(quantity)
from table
group by item_id, cost,price,quantity
但这不会总结数量,而是单独组它
我想拿出这个结果
item_id cost price quantity
1 32.00 35.00 11
2 43.00 52.00 8
通过从组数量将显示此错误
i've tried that , this error shows, "Column 'XXXX.quantity' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
"
删除'group by'中的'quantity'。 –
@FelixPamittan:此错误将显示“列'XXXX.quantity'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。 ” – marlonpd
“您是否向我们显示实际查询?我认为你错误地输入了一些东西,或者从组中删除数量就会很好。 – Andrea