I just got a new data source for my application that inserts data into the Derby database only when it changes. As a rule, the missing data is beautiful - I draw a linear diagram with the data (value over time), and I simply draw a line between two points, extrapolating the expected value at any given point. The problem is that since missing data in this case means “draw a straight line”, the graph would be wrong if I did this.
I can fix this in two ways: I could create a new class that processes the missing data in different ways (which can be difficult due to the prefuse method, the drawing library I use processes the drawing), or I could duplicate the lines, leaving the y value the same when changing the x value in each row. I could do this in Java, which integrates the database and the renderer, or I can modify SQL.
My question, given a result similar to the one below:
+-------+---------------------+
| value | received |
+-------+---------------------+
| 7 | 2000-01-01 08:00:00 |
| 10 | 2000-01-01 08:00:05 |
| 11 | 2000-01-01 08:00:07 |
| 2 | 2000-01-01 08:00:13 |
| 4 | 2000-01-01 08:00:16 |
+-------+---------------------+
Assuming I request it at 8:00:20, how can I make it look like the following using SQL? Basically, I duplicate a line every second until it is already done. receivedunique for all purposes and goals (this is not so, but it will be associated with the proposal WHEREin the request).
+-------+---------------------+
| value | received |
+-------+---------------------+
| 7 | 2000-01-01 08:00:00 |
| 7 | 2000-01-01 08:00:01 |
| 7 | 2000-01-01 08:00:02 |
| 7 | 2000-01-01 08:00:03 |
| 7 | 2000-01-01 08:00:04 |
| 10 | 2000-01-01 08:00:05 |
| 10 | 2000-01-01 08:00:06 |
| 11 | 2000-01-01 08:00:07 |
| 11 | 2000-01-01 08:00:08 |
| 11 | 2000-01-01 08:00:09 |
| 11 | 2000-01-01 08:00:10 |
| 11 | 2000-01-01 08:00:11 |
| 11 | 2000-01-01 08:00:12 |
| 2 | 2000-01-01 08:00:13 |
| 2 | 2000-01-01 08:00:14 |
| 2 | 2000-01-01 08:00:15 |
| 4 | 2000-01-01 08:00:16 |
| 4 | 2000-01-01 08:00:17 |
| 4 | 2000-01-01 08:00:18 |
| 4 | 2000-01-01 08:00:19 |
| 4 | 2000-01-01 08:00:20 |
+-------+---------------------+
Thank you for your help.