samedi 27 juin 2015

SQLITE: The request with the last value in another row

Have a database. There is a lot of data.

Column databases: time, type, price, bid, ask.

The data looks:

1 12:01, 2, 129,12
2 12:02, 1, 129.1, 129.2
3 12:02, 2, 129.1
4 12:03, 2, 129.12
5 12:03, 2, 129.2
6 12:04, 1, 129.2, 129.5
7 12:04, 2, 129.2
8 12:04, 2, 129.4
9 12:05, 2, 129.5

When I make a request to the database WHERE type=2, I want along with the request show at what price relative to the bid and ask prices

For example:

Request was done, which showed

12:04, 2, 129.2
12:04, 2, 129.4
12:05, 2, 129.5

Actually, I need to display the following result

12:04, 2, 129.2, 129.2, 129.5
12:04, 2, 129.4, 129.2, 129.5
12:05, 2, 129.5, 129.2, 129.5

Two data sources are recorded in this table. In one case, type 1, in another type 2. Not dependent from each other.

how more correctly to make? When you request WHERE TYPE=2 take the last value where type 1? And how to do so?

Or when saved to a database value with type=2 to indicate the last value in columns bid,ask?

Aucun commentaire:

Enregistrer un commentaire