От:
News Subsystem <news@news.hub.org>
Дата:
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: groups-abuse@google.com 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: <2bc49454-76cf-450f-8b61-e0a8e4e33dc6@googlegroups.com> Subject: What query could I use to draw a support line on a stock chart? From: Nick Injection-Date: Tue, 05 Mar 2013 03:15:32 +0000 Content-Type: text/plain; charset=ISO-8859-1 To: pgsql-general@postgresql.org 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