Mon, 04 Mar 2013 19:15:32 -0800 (PST) 04 Mar 2013 19:15:32 -0800 (PST) X-Newsgroups: pgsql.general Date: Mon, 4 Mar 2013 19:15:31 -0800 (PST) Complaints-To: [email protected] Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.87.68.198; posting-account=96NFGAoAAABqgpEyKCN3YH2nEalcbJuu User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <[email protected]> Subject: What query could I use to draw a support line on a stock chart? From: Nick <[email protected]> Injection-Date: Tue, 05 Mar 2013 03:15:32 +0000 Content-Type: text/plain; charset=ISO-8859-1 To: [email protected]
Using this basic chart as an example, how could I write a query that would give me the lowest points of a trendline? chart = http://nboutelier.s3.amazonaws.com/images/support_line.png Here's the data INSERT INTO data (date,price) VALUES (0,3); INSERT INTO data (date,price) VALUES (1,4); INSERT INTO data (date,price) VALUES (2,2); INSERT INTO data (date,price) VALUES (3,7); INSERT INTO data (date,price) VALUES (4,3); INSERT INTO data (date,price) VALUES (5,8); INSERT INTO data (date,price) VALUES (6,3); INSERT INTO data (date,price) VALUES (7,6); INSERT INTO data (date,price) VALUES (8,4); INSERT INTO data (date,price) VALUES (9,9); INSERT INTO data (date,price) VALUES (10,4); INSERT INTO data (date,price) VALUES (11,6); The query would return the results 10 | 4 6 | 3 2 | 2 -- Sent via pgsql-general mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
