次のようなテーブルがあります。
TYPE GROUP VALUE
----- ----- -----
0 0 10
0 0 60
0 1 20
1 0 30
1 1 40
1 1 10
TYPE および TYPE;GROUP ごとの合計が必要です。TYPE & TYPE;GROUP にインデックスを作成しました。
object ClientDataSet1: TClientDataSet
IndexDefs = <
item
Name = 'ClientDataSet1Index1'
Fields = 'TYPE'
GroupingLevel = 1
end
item
Name = 'ClientDataSet1Index2'
Fields = 'TYPE;GROUP'
GroupingLevel = 2
end>
IndexName = 'ClientDataSet1Index1'
そして2つの集合体を作成しました
object ClientDataSet1: TClientDataSet
Aggregates = <
item
Active = True
AggregateName = 'Agg1'
Expression = 'SUM(VALUE)'
GroupingLevel = 1
IndexName = 'ClientDataSet1Index1'
end
item
Active = True
AggregateName = 'Agg2'
Expression = 'SUM(VALUE)'
GroupingLevel = 2
IndexName = 'ClientDataSet1Index2'
end>
AggregatesActive = True
ClientDataset インデックスが ClientDataSet1Index1 に設定されているため、Agg2 は計算されません。ClientDataset.IndexName = ClientDataSet1Index2 の場合、Agg2 は機能しますが、Agg1 は機能しません:( 一度に 1 つの clientdataset インデックスしか指定できないため、複数のグループ化レベルは許可されていないようです。
何か不足していますか?
回避策は、clientdataset のクローンを作成し、そこに別の集計を作成することです。ちょっと不便。
【D2006使用時】
ありがとう