Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Created December 9, 2021 02:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arachnid/dfd374886a3e6b0a0eb17b26703d776a to your computer and use it in GitHub Desktop.
Save Arachnid/dfd374886a3e6b0a0eb17b26703d776a to your computer and use it in GitHub Desktop.
SELECT
FORMAT_DATE("%b %Y", dt) AS month,
FORMAT("%.4f", eth_revenue) AS eth,
FORMAT("%.2f", usd_revenue) AS usd
FROM (
SELECT
DATE_TRUNC(EXTRACT(DATE
FROM
event_timestamp AT TIME ZONE "Asia/Singapore"), month) AS dt,
SUM(cost) AS eth_revenue,
SUM(cost * ether_price) AS usd_revenue
FROM
`ens-manager.registrations.registration_periods`
WHERE
event_timestamp >= timestamp '2021-01-01 00:00:00 Asia/Singapore'
AND event_timestamp <= timestamp '2021-11-29 19:21:50 UTC'
GROUP BY
dt)
ORDER BY
dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment