В процессе агрегирования Валюта покупки и продажи сопоставляются в соответствии с флагом покупки и продажи.
При агрегировании суммы покупки, если флаг покупки и продажи равен B, сопоставьте валюту покупки с валютой покупки или, в противном случае, с валютой продажи.< /p>
При агрегировании суммы продажи, если флаг покупки и продажи равен B, сопоставьте валюту продажи с валютой покупки или иначе с валютой продажи.
Если ничего не совпадает, пока ничего не совпадает. группировки, то совокупное значение суммы покупки или продажи будет равно 0.
Суммы покупки и продажи указаны в формате BigDecimal, дата расчета — в LocalDate, а исполнение дата и время указаны в ZonedDateTime.
Это SQL-запрос для справки:
Код: Выделить всё
select
f.business_date,
f.trade_key,
f.account key,
f.currency_pair,
f.execution_date_time,
f.buy_sell_flag,
f.buy_currency,
convert( float, f.buy_amount) as buy_amount,
f.sell_currency,
convert( float, f.sell_amount ) as sell_amount,
f.local_currency,
convert( float, f.local_amount ) as local_amount,
isnull (
( select convert (float, sum(isnull( g.local_amount, 0.0 ) ) )
from group g
where f.account_key = g.account_key
and g.buy_currency = case
when f.buy_sell_flag = 'B' then f.buy_currency
else f.sell_currency
end
and f.settlement_pay_date = g.settlement_pay_date
and g.buy_sell_flag = 'B'
and dateadd(mi, -convert (int, lookback_time) , f.execution date_time) < g.execution_date_time
and f.execution_date_time >= g.execution_date_time
) , 0
) as sum_buy_amount,
isnull (
(select convert (float, sum(isnull( g.local_amount, 0.0 ) ) )
from group g
where f.account_key = g.account_key
and g.sell_currency = case
when f.buy_sell_flag = 'B' then f.buy_currency
else f.sell_currency
end
and f.settlement_pay_date = g.settlement_pay_date
and g.buy_sell_flag = 'S'
and dateadd(mi, -convert (int, lookback_time ) , f.execution date_time) < g.execution_date_time
and f.execution_date_time >= g.execution_date_time
), 0
) as sum_sell_amount
f refers to the list of trades
Подробнее здесь: https://stackoverflow.com/questions/784 ... nd-also-fi