从表中获取以下结果的 mysql 查询是什么?金额栏的加法应根据invoiceID进行。
问问题
34 次
3 回答
1
SELECT @rownum := @rownum + 1 AS ID, InvoiceID, SUM(AMOUNT)
FROM <tablename>, (SELECT @rownum := 0) r
GROUP BY InvoiceID
于 2012-09-25T10:19:11.493 回答
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
SQL Fiddel 演示
于 2012-09-25T10:21:11.383 回答
0
select ID,InvoiceID, SUM(Amount)
from <table>
group by InvoiceID
于 2012-09-25T10:26:10.080 回答