I am trying to achieve the below requirement. I need your help to know if this can be acieved?
Highlevel Requirement:
To fetch data from a table grouped by 15 minute intervals on timestamp column.
1. i need to create an output file which will have fields: key-1, data-1, metric-1, metric-2, metric-3...metric-96.
2. i need to sum the data-1 values for every 15 minute interval in the table to arrive at metric-1, metric-2 value and so on.
Scenario:
i have product-id (key), dept, qty and timestamp on a table. I need to sum the qty field for all unique produt-id/dept combination for the first 15 minutes (00:00 hrs to 00:15 hrs) to get the sum(qty) as metric-1. Again sum(qty) for next 15 mins interval (00:16 hrs to 00:30 hrs) to get metric-2 and so on for all the 15 minute interval (96 intervals in 24 hours). Now the output needs to be written with product-id, dept, and the 96 metric values.
Question: is it possible to get the data from the table by just one query by calling a paragraph 96 times to get the 96 interval data and create one output record? Is there any better way to achieve this?
Please let me know if the requirement is not clear or if more inputs are required.
Sample Input data: (this is what i have from the table)
Key dept Qty timestamp
1 X 5 2008-04-01-00.00.00.000000
1 X 5 2008-04-01-00.10.00.000000
1 X 5 2008-04-01-00.20.00.000000
1 X 5 2008-04-01-00.25.00.000000
1 X 5 2008-04-01-01.01.00.000000
1 X 5 2008-04-01-01.05.00.000000
1 X 5 2008-04-01-01.10.00.000000
1 X 5 2008-04-01-01.15.00.000000
1 X 5 2008-04-01-01.20.00.000000
1 X 5 2008-04-01-01.25.00.000000
1 X 5 2008-04-01-01.28.00.000000
1 X 5 2008-04-01-01.30.00.000000
Required output data - output from query: (this is what i need in the output file. Note: Metric is sum(qty) for that time interval - every 15 mins)
Key dept Metric-1 metric-2 metric-3 metric-4 metric-5 ....... metric-96
1 X 10 10 0 0 20 .......
Thanks,
Ajay