From: News Subsystem <news(at)news(dot)hub(dot)org>
To: undisclosed-recipients:;
Subject:
Date: 2013-03-05 03:15:34
Message-ID: 201303050315.r253FYWn087798@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)google(dot)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(at)googlegroups(dot)com>
Subject: What query could I use to draw a support line on a stock chart?
From: Nick <nboutelier(at)gmail(dot)com>
Injection-Date: Tue, 05 Mar 2013 03:15:32 +0000
Content-Type: text/plain; charset=ISO-8859-1
To: pgsql-general(at)postgresql(dot)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

Browse pgsql-general by date

  From Date Subject
Next Message dhaval257 2013-03-05 04:17:06 PostgreSQL connect with Visual C++
Previous Message Daniel Farina 2013-03-04 23:12:55 Re: [HACKERS] Floating point error