i have this problem

i have
Trans table
@TransID | Date | DiscountPercent | DiscountCurrency
tr-1 | 1/1/2005 | 0 | 1000

Trans Details table
@TransID | ProductID | QtyBuy | SellPrice |
tr-1 | prod1 | 10 | 100
tr-1 | prod2 | 10 | 10
tr-1 | prod3 | 15 | 100

if DiscountCurrency is > 0 then
TotalDiscount = DiscountCurrency
else
TotalDiscount = (qty * SellPrice for tr-1) * DiscountPercent/100
endif

question :
the report want to show per GROUP TransID
TransID | TotalDiscount | Total (TotalDiscount - (qtyBuy*SellPrice for Each TransID)) -> how to do something like this??????

thanks