Sum of costprices in Query

hi
All ,Here am calculating the sum of all the costprices display it into one field ,but here my problem is that cost price is display method how can I do the display method in while statement,please help me

while select sum(qty),sum(cost price) from _ProjItemTrans group by CategoryId,projid
where _ProjItemTrans.ProjId == ProjId.text()
{
Ttsbegin;
Projcate.ProjId = _ProjItemTrans.ProjId;
Projcate.CategoryId = _ProjItemTrans.CategoryId;
Projcate.Qty1 = _ProjItemTrans.Qty;
Projcate.ValueActual = _ProjItemTrans.costPrice();
Projcate.CategoryType = ProjCategoryType::Item;
Projcate.insert ();
ttscommit;
}
Thanks in Advance
Nani