Replace lag function with lead to calculate coin balance deltas

pull/3140/head
Victor Baranov 5 years ago
parent 4abef9d535
commit 5d65fc4c57
  1. 2
      apps/explorer/lib/explorer/chain/address/coin_balance.ex

@ -78,7 +78,7 @@ defmodule Explorer.Chain.Address.CoinBalance do
where: not is_nil(cb.value),
order_by: [desc: :block_number],
limit: ^page_size,
select_merge: %{delta: fragment("coalesce(lag(value, 1) over (order by block_number desc), 0) - value")}
select_merge: %{delta: fragment("value - coalesce(lead(value, 1) over (order by block_number desc), 0)")}
)
end

Loading…
Cancel
Save