Reputation: 4259
I write a query to multiply to colums now i would like to sum up the result that i am getting can any one give me an idea
this is what i wrote
select Rate,Qty,(Rate*Qty) as result
from tblName
I will get result say for example 40 90
now i would like to sum these results
Upvotes: 8
Views: 65355
Reputation: 5105
Original Answer
select Sum(Rate) as Rate, Sum(Qty) as Qty, Sum(Rate*Qty) as Result from tblName
EDIT - Try this..
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
Upvotes: 12