在選擇查詢將其放置在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