Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Last active January 11, 2017 05:57
Show Gist options
  • Save yyoshiki41/742763bfc40ed001c90d58dd689a48e9 to your computer and use it in GitHub Desktop.
Save yyoshiki41/742763bfc40ed001c90d58dd689a48e9 to your computer and use it in GitHub Desktop.
当月の獲得数から、着地予想を出す。(線形近似)
SELECT
count(*) AS count,
floor(
COUNT(*) * date_part('day', DATE_TRUNC('month', now() + '1 months') + '-1 days') / date_part('day', now())
) AS forecast
FROM user
WHERE registered_at >= CAST(DATE_TRUNC('month', now()) AS TIMESTAMP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment