-5
SELECT item_id,
CREDITBAL= (SELECT Sum(quantity)
FROM axi_quantity_registers
WHERE from_where != 'OPENING'
AND transaction_type = 'C'),
OPENBAL = (SELECT Sum(quantity)
FROM axi_quantity_registers
WHERE from_where = 'OPENING'),
DEBITBAL = (SELECT Sum(quantity)
FROM axi_quantity_registers
WHERE transaction_type = 'D')
FROM axi_quantity_registers
歡迎堆棧溢出。請花點時間參加[Tour](https://stackoverflow.com/tour)並閱讀[how-to-ask](https://stackoverflow.com/questions/how-to-ask)以獲取爲您的問題提供更好的答案 –
您真的希望有人幫助解答您的問題嗎?解釋你想要達到什麼。添加樣本數據和預期結果 –
item_id CREDITBAL OPENBAL DEBITBAL 1 200 500 250 – Nikita