Dear all,

This is my first post to this mailing list, I hope it is a relevant question.

I have a table with Forex (currency exchange) data with the following schema:

CREATE TABLE eurusd (
    date   TEXT NOT NULL PRIMARY KEY,
    open   REAL NOT NULL,
    high   REAL NOT NULL,
    low    REAL NOT NULL,
    close  REAL NOT NULL
);

The granularity of the data is one minute, for example:

INSERT INTO eurusd (date, open, high, low, close) VALUES (
    '2011-11-01 00:01:00', '1.1212', '1.2323', '1.3434', '1.4545'
);

For the analysis of the data it is important to aggreate table rows using other timeframes. If I want to do analysis of data aggregated by months I can use the following query:

SELECT MAX(high) AS High, MIN(low) as Low,
    STRFTIME("%Y-%m-%d", date) as Date
    FROM eurusd GROUP BY STRFTIME("%Y-%m-%d", date);

In the same way I can aggregate the data by days and hours.

The problem is that I have to aggregate and analyze the data with other less conventional time frames, like 5 minutes, 15 minutes, or even 23 minutes.

Is is possible to do that with an SQLite Select? Could somebody send me an example? If not, is it possible to solve the problem writting my own aggretation function with SQLite C API?

Many thanks for your help

Rafael Garcia


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to