with all_r as (
SELECT
ORIGIN_FROM_ADDRESS as ua,
BLOCK_TIMESTAMP :: date as date,
rank() over(
partition by ORIGIN_FROM_ADDRESS
ORDER by
BLOCK_TIMESTAMP asc
) as rank
from
ethereum.defi.ez_dex_swaps
where
TOKEN_OUT = lower ('{{contract_address}}')
)
SELECT
date,
count(DISTINCT ua) as "Buyers Count"
from
all_r
where
rank > 1 and date >= current_date - {{last_x_days}}
GROUP by
1
ORDER by
1 desc