I have a aggregation query used $match at 1st stage and then used $group at 2nd stage with two fields(side and Settlementdate and sum of quantity. So result will be as below:
{
Id: { side: SELL,SettlementDate:2024-05-10},
TotalQty=100000
}
{
Id: { side: BUY,SettlementDate:2024-05-10},
TotalQty=240000
}
Here i want final result as below:
{
Id: { side: SELL,SettlementDate:2024-05-10},
SellTotalQty=100000
}
{
Id: { side: BUY,SettlementDate:2024-05-10},
BuyTotalQty=240000
}
{TotalQty:140000} ----> this is BuyTotalQty-SellTotalQty