从表中获取以下结果的mysql查询是什么?应根据invoiceID执行金额列中的添加。
答案 0 :(得分:1)
SELECT @rownum := @rownum + 1 AS ID, InvoiceID, SUM(AMOUNT)
FROM <tablename>, (SELECT @rownum := 0) r
GROUP BY InvoiceID
答案 1 :(得分:0)
试试这个:
select @i:=@i+1 AS id,a.*
from
(select InvoiceID,sum(Amount) as Amount
from your_table
group by InvoiceID)a,(SELECT @i:=0) r
答案 2 :(得分:0)
select ID,InvoiceID, SUM(Amount)
from <table>
group by InvoiceID