I can do a while loop and count but that takes more time. I cannot use an
x++ query because my quiery will vary with users selections.
Any ideas?
Should work:
Try this sample:
QueryRun qr;
Query query = new Query();
QueryBuildDataSource qbds;
CustTable custTable;
;
qbds = query.addDataSource(tablenum(CustTable));
qbds.addGroupByField(fieldnum(CustTable, CountryRegionId));
qbds.addSelectionField(fieldnum(CustTable, RecId), SelectionField::Count);
qr = new QueryRun(query);
while (qr.next())
{
custTable = qr.get(tablenum(CustTable));
info(strfmt("in Country %1, there are %2 customers",
custTable.CountryRegionId, custTable.RecId));
}
For each country you get the count.
Regards
Patrick