Skip links

Query nesneleri ile GroupBy ve Sum Almak

Query nesneleri ile GroupBy ve Sum Almak

Select Sum(AmountMst) from LedgerTrans
Group By LedgerTrans.Voucher, LedgerTrans.TransDate
koduna denk olan query alttaki gibi yazılabilir:

Query q;
QueryRun qr;
QueryBuildDataSource qbdsLedgerTrans;
LedgerTrans ledgerTrans;
;
q = new Query();
qbdsLedgerTrans = q.addDataSource(tableNum(LedgerTrans));
qbdsLedgerTrans.addSortField(FieldNum(LedgerTrans, Voucher));
qbdsLedgerTrans.addSortField(FieldNum(LedgerTrans, TransDate));
qbdsLedgerTrans.orderMode(OrderMode::GroupBy);
qbdsLedgerTrans.addSelectionField(FieldNum(LedgerTrans, AmountMST), SelectionField::Sum);
qr = new QueryRun(q);
while(qr.next())
{
ledgerTrans = qr.get(TableNum(LedgerTrans));
this.send(ledgerTrans);
}

Join the Discussion