• J Livingston SQL (5/8/2014)


    ChrisM@Work (5/8/2014)


    Otherwise you will get answers like this:

    SELECT *, Trend = ([Week]/5.0) * MAX(Forecast) OVER(PARTITION BY [TYPE])

    FROM #REport

    Which exactly meets your requirements (apart from the trivial matter of rounding) but is almost certainly incorrect.

    Chris ...your mind reading skills are quite extraordinary πŸ™‚

    but have a suspicion that OP has oversimplified........we can wait and see

    J Livingstone - you give me way too much credit for a Wild Guess πŸ˜€

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden