static void Test_Query(Args _args)
{
CustTable custTable;
Query query = new Query();
QueryRun qr = new queryRun(query);
QueryBuildDataSource qbds = qr.query().addDataSource(tableNum(CustTable));
QueryBuildRange qbrAccN = qbds.addRange(fieldNum(CustTable,AccountNum));
// QueryBuildRange qbrCountry = qbds.addRange(fieldNum(CustTable,Country));
QueryBuildFieldList qbfl = qbds.fields();
;
qbrAccN.value('4000..4050');
qbrAccN.status(RangeStatus::Locked);
//qbrCountry.value('CA..NO');
qbfl.addField(fieldNum(CustTable,CreditMax),SelectionField::Sum);
qbfl.addField(fieldnum(CustTable,RecId),SelectionField::Count);
// qbds.addSortField(fieldnum(CustTable,Country));
qbds.addSortField(fieldNum(CustTable,Currency));
qbds.orderMode(OrderMode::GroupBy);
if (qr.prompt())
{
while (qr.next())
{
custTable = qr.get(tableNum(CustTable));
print strfmt("%1 %2 %3 (%4 records)",/*custTable.Country*,*/custTable.Currency,
num2str(custTable.CreditMax,10,2,0,0),custTable.RecId);
}
}
pause;
}
No comments:
Post a Comment