• sayedkhalid99 (10/2/2012)


    i have changed the my input and output and add date and comments to make it clear, for multiple entry with in a month it shall take the last entry.

    ....

    Please confirm that your desired results are correct for sector C, and add a few extra sample rows for B and C, including multiple rows for a single month. It will aid disambiguation. Thanks.

    EDIT: more sample data requested.

    “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