At my job, I need to take some granular data collected in a twentieth of a mile and then roll it up to a tenth of a mile. This task is done with python scripts, but I was wondering if I can do it with a materialized view. Here is an example of what the data looks like it is simplest form, and what I would like the view to look like.
Simplest form:
| Route Number | Beginning Mile Post | Ending Mile Post | Route Length |
|---|---|---|---|
| 001 | 0 | 0.02 | 105.6 |
| 001 | 0.02 | 0.04 | 105.6 |
| 001 | 0.04 | 0.06 | 105.6 |
| 001 | 0.06 | 0.08 | 105.6 |
| 001 | 0.08 | 0.10 | 105.6 |
| 001 | 0.10 | 0.12 | 105.6 |
| 001 | 0.12 | 0.14 | 105.6 |
This is what I want the view to produce:
| Route Number | Beginning Mile Post | Ending Mile Post | Route Length |
|---|---|---|---|
| 001 | 0 | 0.1 | 528 |
| 001 | 0.1 | 0.14 | 211.2 |
I have tried using the rollup, sum, MOD, remainder, but not sure how to use them correctly. I'm not even sure if this is possible through a view or not.
I will accept all suggestions and ideas.