1
我想用addselectionfield選擇4字段。從這4個字段2是總計(總和)字段。 如何使用查詢選擇聚合字段?
我做了以下內容:
date fromDate = systemDateGet();
date toDate = (systemDateGet() + 25);
query = new Query();
qbds = query.addDataSource(tableNum(MyTable));
qbds.addSelectionField(fieldNum(MyTable, DateField));
qbds.addSelectionField(fieldNum(MyTable, USDAmountField), SelectionField::Sum);
qbds.addSelectionField(fieldNum(MyTable, CurrencyNameField));
qbds.addSelectionField(fieldNum(MyTable, EURAmountField), SelectionField::Sum);
qbr = qbds.addRange(fieldNum(MyTable, DateField));
qbr.value(queryRange(fromDate, toDate));
queryRun = new QueryRun(query);
在調試,我得到下面的SELECT語句中queryRun:
SELECT SUM(EURAmountField) FROM MyTable(MyTable_1)
WHERE ((DateField >= {ts '2014-04-01 00:00:00.000'}
AND DateField <= {ts'2014-04-26 00:00:00.000'}))
那麼是什麼原因它只選擇最後一個addSelectionField和我所擁有的要做所有的字段,因爲我已經寫在addSelectionFields?