Hi,
I have a table, category_rate, where I am collecting stats per process as follows:
Server Process Category Day Time Value
================================================
serv1 a1 Update_FL 15/9 09:00 100
serv1 a2 Update_FL 15/9 09:00 95
serv2 b1 Downrate_X 15/9 09:00 14
serv2 b2 Update_FL 15/9 09:00 1200
serv1 a1 Update_FL 15/9 09:01 25
serv1 a2 Update_FL 15/9 09:01 195
serv2 b1 Downrate_X 15/9 09:01 87
serv2 b2 Update_FL 15/9 09:01 200
I want to summarise this table into a category_rate_daily table where I am interested in the columns: Category, Day, Avg Value and Max Value
If I summarise this manually I would add up the similar categories for the same time to get their overall values for each time interval:
Category Day Time Value
=============================
Update_FL 15/9 09:00 1395
Downrate_X 15/9 09:00 14
Update_FL 15/9 09:01 420
Downrate_X 15/9 09:01 87
and then would get the average for the day by adding the values for each time interval and dividing by the number of intervals (in this case 1395 + 420 divided by 2 for Update_FL) and get the max as the highest value for a single time entry (in this case 1395 for Update_FL)
I'm wondering how do I do this in PL/SQL without physically creating the intermediate table to get the totals per time interval.
If I create a Cursor to create the intermediate table in memory do I need to loop through this cursor to get the average and max values? I need this to be performant and in a day there are 1440 minutes so I would have to loop this many times per Category and there could be 100 categories. Is there a better solution?
Thanks for your help,
Toddyl
I have a table, category_rate, where I am collecting stats per process as follows:
Server Process Category Day Time Value
================================================
serv1 a1 Update_FL 15/9 09:00 100
serv1 a2 Update_FL 15/9 09:00 95
serv2 b1 Downrate_X 15/9 09:00 14
serv2 b2 Update_FL 15/9 09:00 1200
serv1 a1 Update_FL 15/9 09:01 25
serv1 a2 Update_FL 15/9 09:01 195
serv2 b1 Downrate_X 15/9 09:01 87
serv2 b2 Update_FL 15/9 09:01 200
I want to summarise this table into a category_rate_daily table where I am interested in the columns: Category, Day, Avg Value and Max Value
If I summarise this manually I would add up the similar categories for the same time to get their overall values for each time interval:
Category Day Time Value
=============================
Update_FL 15/9 09:00 1395
Downrate_X 15/9 09:00 14
Update_FL 15/9 09:01 420
Downrate_X 15/9 09:01 87
and then would get the average for the day by adding the values for each time interval and dividing by the number of intervals (in this case 1395 + 420 divided by 2 for Update_FL) and get the max as the highest value for a single time entry (in this case 1395 for Update_FL)
I'm wondering how do I do this in PL/SQL without physically creating the intermediate table to get the totals per time interval.
If I create a Cursor to create the intermediate table in memory do I need to loop through this cursor to get the average and max values? I need this to be performant and in a day there are 1440 minutes so I would have to loop this many times per Category and there could be 100 categories. Is there a better solution?
Thanks for your help,
Toddyl