Skip to content

Instantly share code, notes, and snippets.

@archiewood
Last active June 7, 2024 02:23
Show Gist options
  • Save archiewood/6ef52e08af093a34ebb78f843f9f928a to your computer and use it in GitHub Desktop.
Save archiewood/6ef52e08af093a34ebb78f843f9f928a to your computer and use it in GitHub Desktop.
Linear Regression in SQL
SELECT
regr_slope(num_orders, sales) AS slope,
regr_intercept(num_orders, sales) AS intercept,
regr_r2(num_orders, sales) AS r_squared
FROM orders_by_state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment