I posted before and did not provide enough detail and am not able to edit the post so though that I would try again. I am only showing relavent columns of data that are in the Teradata table.
I am wondering if there is a way to write a script that would look at individual rows of data to caculate services levels for me. I can do this in Excel with a formula (TAT column is a formula which is Ship_Dt-Recd_Dt) * Shp_cards ) for each row of data and then sum up that result and divide it by the sum of Shp_cards to come up with a weighted service level. I hope that I am providing enough detail this time. Maybe there isn't a way but thought that I would ask the professionals :-)
Solved! Go to Solution.
SELECT a.* ,(ship_dt - recd_dt ) * shp_cards AS tat ,SUM(CAST(tat AS FLOAT)) OVER() / SUM(shp_cards ) OVER() AS weighted_avg2 FROM vt1 AS a;
Note that this will put the weighted average value on each row of the output (but that is SQL).
Thanks Dave. I wish there was someway to have just the result of 1.43 and not all of the rows that the calculations were based off of. Thanks for your help.