Query editor
withuser_detail as(selectuser_address,count(*) as transaction_count,min(block_time) as initial_block_time,max(block_time) as last_block_time,date_diff('day', min(block_time), now()) as lz_age_days,count(distinct source_chain_id) as active_source_chain_count,count(distinct destination_chain_id) as active_destination_chain_count,count(distinct transaction_contract) as active_transaction_contract_count,count(distinct date_trunc('day', block_time)) as active_days_count,count(distinct date_trunc('week', block_time)) as active_weeks_count,count(distinct date_trunc('month', block_time)) as active_months_count,-- coalesce(sum(amount_usd / power(10, p.decimals) * p.price), 0) as amount_usdcoalesce(sum(amount_usd), 0) as amount_usdfrom layerzero.sendgroup by 1),user_rank as (select*,ROW_NUMBER() OVER (ORDER BY transaction_count DESC) AS transaction_count_rank,ROW_NUMBER() OVER (ORDER BY lz_age_days DESC) AS lz_age_days_rank,ROW_NUMBER() OVER (ORDER BY active_source_chain_count DESC) AS active_source_chain_count_rank,ROW_NUMBER() OVER (ORDER BY active_destination_chain_count DESC) AS active_destination_chain_count_rank,ROW_NUMBER() OVER (ORDER BY active_days_count DESC) AS active_days_count_rank,ROW_NUMBER() OVER (ORDER BY amount_usd DESC) AS amount_usd_rank,COUNT(*) OVER () AS total_countfrom user_detail),-- select-- PERCENTILE_DISC(0.1) WITHIN GROUP(ORDER BY transaction_count) AS percentile_10th_transaction_count-- from user_rank-- group by user_addresstop_info as (select'Interection_times' as indicator,case when transaction_count_rank = round(0.1 * total_count) then transaction_count end as percentile_10th,case when transaction_count_rank = round(0.2 * total_count) then transaction_count end as percentile_20th,case when transaction_count_rank = round(0.3 * total_count) then transaction_count end as percentile_30th,case when transaction_count_rank = round(0.4 * total_count) then transaction_count end as percentile_40th,case when transaction_count_rank = round(0.5 * total_count) then transaction_count end as percentile_50th,case when transaction_count_rank = round(0.6 * total_count) then transaction_count end as percentile_60th,case when transaction_count_rank = round(0.7 * total_count) then transaction_count end as percentile_70th,case when transaction_count_rank = round(0.8 * total_count) then transaction_count end as percentile_80th,case when transaction_count_rank = round(0.9 * total_count) then transaction_count end as percentile_90th,case when transaction_count_rank = round(1 * total_count) then transaction_count end as percentile_100th,total_countfrom user_rankwhere transaction_count_rank = round(0.1 * total_count)or transaction_count_rank = round(0.2 * total_count)or transaction_count_rank = round(0.3 * total_count)or transaction_count_rank = round(0.4 * total_count)