Query editor
SELECTCOUNT(1) AS actions,COUNT(1) FILTER (WHERE action = 'deposit') AS actions_deposit,COUNT(1) FILTER (WHERE action = 'withdraw') AS actions_withdraw,COUNT(DISTINCT user) AS user,COUNT(DISTINCT user) FILTER (WHERE action = 'deposit') AS user_deposit,COUNT(DISTINCT user) FILTER (WHERE action = 'withdraw') AS user_withdraw,coalesce(SUM(amount_usd) FILTER (WHERE action = 'deposit'),0) AS inflow,-coalesce(SUM(amount_usd) FILTER (WHERE action = 'withdraw'),0) AS outflow,coalesce(SUM(amount_usd) FILTER (WHERE action = 'deposit'),0) - coalesce(SUM(amount_usd) FILTER (WHERE action = 'withdraw'),0) AS daily_net_flow,COUNT(1) FILTER (WHERE action = 'deposit') * 1.00 / COUNT(DISTINCT user) FILTER (WHERE action = 'deposit') AS avg_deposit_action,COUNT(1) FILTER (WHERE action = 'withdraw') * 1.00 / COUNT(DISTINCT user) FILTER (WHERE action = 'withdraw') AS avg_withdraw_action,try( coalesce(SUM(amount_usd) FILTER (WHERE action = 'deposit'),0) / (COUNT(DISTINCT user) FILTER (WHERE action = 'deposit'))) AS avg_deposit_usd,try( coalesce(SUM(amount_usd) FILTER (WHERE action = 'withdraw'),0) / (COUNT(DISTINCT user) FILTER (WHERE action = 'withdraw'))) AS avg_withdraw_usdFROM query_2274039