如何对具有特定字段的公用表进行分组?
我在(dt.fieldname2Id('BatchNo'))
上遇到语法错误
这是我的代码:
Common common;
SysDictTable dt;
dt = SysDictTable::newName('Table1');
common = dt.makeRecord();
while select count(RecId) from common
group by common.(dt.fieldname2Id('BatchNo')) //syntax Error here
where common.(dt.fieldname2Id('flag'))==1
{
info(int642str(Common.Recid));
}
答案 0 :(得分:4)
您可以改用Query
:
Common common;
SysDictTable dt;
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun queryRun;
dt = SysDictTable::newName('SalesTable');
common = dt.makeRecord();
qbds = query.addDataSource(common.TableId);
qbds.addGroupByField(dt.fieldname2Id('CustAccount'));
queryRun = new QueryRun(query);
while (queryRun.next())
{
...
}