我写了一个查询来乘以colums现在我想总结一下我得到的结果可以任何人给我一个想法
这就是我写的
select Rate,Qty,(Rate*Qty) as result
from tblName
我会得到结果例如40 90
现在我想总结这些结果
答案 0 :(得分:8)
原始答案
select Sum(Rate) as Rate, Sum(Qty) as Qty, Sum(Rate*Qty) as Result from tblName
编辑 - 试试这个..
select
0 as TotalRow,
Rate,
Qty,
(Rate*Qty) as Result
from tblName
UNION ALL
select
1 as TotalRow,
Sum(Rate) as Rate,
Sum(Qty) as Qty,
Sum(Rate*Qty) as Result
from tblName
Order By TotalRow
答案 1 :(得分:3)
SELECT SUM(Rate*Qty) as Result
FROM tblName