Ert*_*Ert 2 x++ axapta dynamics-ax-2012
我有这样的用户表
ID Date Value
---------------------------
1001 31 01 14 2035.1
1002 31 01 14 1384.65
1003 31 01 14 1011.1
1004 31 01 14 1187.04
1001 28 02 14 2035.1
1002 28 02 14 1384.65
1003 28 02 14 1011.1
1004 28 02 14 1188.86
1001 31 03 14 2035.1
1002 31 03 14 1384.65
1003 31 03 14 1011.1
1004 31 03 14 1188.86
1001 30 04 14 2066.41
1002 30 04 14 1405.95
1003 30 04 14 1026.66
1004 30 04 14 1207.15
Run Code Online (Sandbox Code Playgroud)
而且我想从这张表中得到一笔钱
ID Date Value Total
---------------------------------------
1001 31 01 14 2035.1 2035.1
1002 31 01 14 1384.65 1384.65
1003 31 01 14 1011.1 1011.1
1004 31 01 14 1187.04 1187.04
1001 28 02 14 2035.1 4070.2
1002 28 02 14 1384.65 2769.3
1003 28 02 14 1011.1 2022.2
1004 28 02 14 1188.86 2375.9
1001 31 03 14 2035.1 6105.3
1002 31 03 14 1384.65 4153.95
1003 31 03 14 1011.1 3033.3
1004 31 03 14 1188.86 3564.76
1001 30 04 14 2066.41 8171.71
1002 30 04 14 1405.95 5180.61
1003 30 04 14 1026.66 4059.96
1004 30 04 14 1207.15 4771.91
Run Code Online (Sandbox Code Playgroud)
我有id,对于第一个月的每个id,它应该写为总值和第二个月的id,它应该添加第一个月+第二个月的值,它应该继续这样.如何在X ++中进行总结?
谁能帮我?
它可以作为表格上的显示方法完成:
display Amount total()
{
return (select sum(Value) of Table
where Table.Id == this.Id &&
Table.Date <= this.Date).Value;
}
Run Code Online (Sandbox Code Playgroud)
根据您的需要更改表格和字段名称.
这可能不是最快的方法.在报告上下文中,为每个id(在地图中)保持运行总计可能更好.
它也可以在这样的选择中完成:
Table table1, table2
while select table1
group Date, Id, Value
inner join sum(Value) of table2
where table2.Id == table1.Id &&
table2.Date <= table1.Date
{
...
}
Run Code Online (Sandbox Code Playgroud)
您需要对所需字段进行分组,因为它是聚合选择.