shawnedwardsDEF 4.3
Updated 2022-11-22
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
›
⌄
with table1 as (
select date(timestamp) as day, token, symbol, token_contract, ifnull(avg (price_usd),0) as price_in_USD
from flow.core.fact_prices
where token != 'Blocto' group by 1,2,3,4)
select trader,
sum (case when token_in_contract = token_contract then token_in_amount * price_in_USD
when token_out_contract = token_contract then token_out_amount*price_in_USD end) as Total_USD_amount
from flow.core.ez_swaps t1 join table1 t2 on
(t1.token_in_contract = t2.token_contract or t1.token_out_contract = t2.token_contract)
and t1.block_timestamp::Date = t2.day
where symbol ilike '{{ticker}}'
and token_in_contract = token_contract
group by 1
order by 2 DESC
limit 5
Run a query to Download Data