web3-proxy/docs/sum_credits_used_by_user.sql
2023-08-07 15:25:10 -07:00

8 lines
265 B
SQL

SELECT SUM(`sum_credits_used`) as sum, rpc_accounting_v2.rpc_key_id, rpc_key.user_id, user.email
FROM `rpc_accounting_v2`
JOIN rpc_key ON rpc_accounting_v2.rpc_key_id=rpc_key.id
JOIN user on rpc_key.user_id=user.id
GROUP BY `rpc_key_id`
ORDER BY sum DESC
LIMIT 100