我有一个表格,如下所示
Amount Factor Month Customer
1 1 2 A
3 1 2 A
4 -1 2 A
2 1 2 B
2 1 2 B
3 -1 2 B
4 1 3 A
5 1 3 A
6 -1 3 A
我想对Amount
和Month
汇总Customer
列。 Amount
应该与Factor
列中的值相乘。
因此,结果应如下所示(可以是同一表或新表的UPDATE
):
Amount Factor Month Customer
0 1 2 A
1 1 2 B
3 1 3 A
答案 0 :(得分:2)
尝试以下
$sysEvent = Get-EventLog -LogName Application -Newest 300
$sysError = $sysEvent | where {$_entryType -match "Information"}
$sysError | Sort-Object EventID | Format-Table EventID, EntryType, Source, TimeWritten, Message -AutoSize
答案 1 :(得分:2)
我想这就是你想要的:
select month, customer, sum(amount * factor) as sum_amount
from t
group by month, customer;
我不确定您为什么要在结果集中使用factor
。