postgresql_slope - tetsuyaf1100/hello-world GitHub Wiki
- create table
CREATE TABLE foo(
id serial PRIMARY KEY,
X integer NOT NULL,
Y integer NOT NULL
);
INSERT INTO foo VALUES (0,10,3);
INSERT INTO foo VALUES (1,20,5);
- slope
SELECT regr_slope(y, x) slope FROM foo;
SELECT regr_intercept(y, x) intercept FROM foo;