• @ Joe Celko:

    You've demonstrated to design the view for YTD_Averages.

    What is your recommendation to get MTD, QTD and ALL_avg?

    As far as I can see, one option would be to UNION (ALL) 4 separate views using different WHERE clauses (resulting in 4 separate scan/seek operation) or to use the approach I posted that will use one table scan and several aggregated CASE statements.

    It's nothing I would start arguing about but learning from.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]