WITH monthly_services AS (
SELECT
DATE_TRUNC('MONTH', BLOCK_TIMESTAMP) AS creation_month,
COUNT(DISTINCT SERVICE_ID) AS monthly_services_created
FROM
crosschain.olas.ez_service_registrations
WHERE
BLOCK_TIMESTAMP >= DATEADD(YEAR, -1, CURRENT_DATE)
GROUP BY
creation_month
)
SELECT
creation_month,
monthly_services_created,
LAG(monthly_services_created) OVER (
ORDER BY
creation_month
) AS previous_month_services,
monthly_services_created - LAG(monthly_services_created) OVER (
ORDER BY
creation_month
) AS month_to_month_change
FROM
monthly_services QUALIFY month_to_month_change > 0
ORDER BY
creation_month;