whileselect ItemId,sum(Qty), sum(QtySec), WrkCtrID, InventSizeId, ConfigId, InventcolorId, UnitId, UnitIdSec
from _NJ_WIP GroupBy ItemId ,WrkCtrID, InventSizeId, ConfigId, InventcolorId, UnitId, UnitIdSec
join Prodid,ACT_ProdCancelId,SalesId, CustAccount, DlvDate
from _prodTable groupby Prodid,ACT_ProdCancelId,SalesId, CustAccount, DlvDate
where _NJ_WIP.WrkCtrId like "01c2"
&& _NJ_WIP.ProdId == _ProdTable.ProdId
static void calculateCommission(Args _args) { InventTable inventTable; CustInvoiceTrans custInvoiceTrans; ; while select CommissionGroupId from inventTable group by CommissionGroupId join sum(LineAmount) from custInvoiceTrans where custInvoiceTrans.itemId == inventTable.ItemId && custInvoiceTrans.invoiceId == "U000033" { ....... } }