General

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
07:07 AM

08-04-2017
07:07 AM

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 :-)

Recd_Dt | Ship_Dt | Shp_cards | TAT |

9/13/2016 | 9/17/2016 | 13 | 52 |

9/13/2016 | 9/14/2016 | 52 | 52 |

9/13/2016 | 9/13/2016 | 10 | 0 |

9/13/2016 | 9/18/2016 | 31 | 155 |

9/13/2016 | 9/15/2016 | 229 | 458 |

9/13/2016 | 9/15/2016 | 141 | 282 |

9/13/2016 | 9/14/2016 | 74 | 74 |

9/13/2016 | 9/17/2016 | 14 | 56 |

9/13/2016 | 9/20/2016 | 16 | 112 |

9/13/2016 | 9/19/2016 | 32 | 192 |

9/13/2016 | 9/15/2016 | 39 | 78 |

2.32 |

Solved! Go to Solution.

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
09:51 AM

1 ACCEPTED SOLUTION

4 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
07:30 AM

08-04-2017
07:30 AM

Hi,

Try this:

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).

Cheers,

Dave

Ward Analytics Ltd - information in motion

www: http://www.ward-analytics.com

www: http://www.ward-analytics.com

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
09:43 AM

08-04-2017
09:43 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
09:51 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

08-04-2017
09:56 AM

08-04-2017
09:56 AM

That is! Thank you so much!!!