Need Help for my Query

  • Hi All,

    This is Naveen Maroju,I unable to get output and please help me on this query.

    Mainly i want groupby Vendorname cloumn for below points.

    1) If he select Month then in that particular month how many weeks then it should display.

    2) If he select month then in that month how many days then it should display.

    Kindly find the attachment and in that what i require exactly output is there in the sheet.

  • maroju1 (9/11/2014)


    Hi All,

    This is Naveen Maroju,I unable to get output and please help me on this query.

    Mainly i want groupby Vendorname cloumn for below points.

    1) If he select Month then in that particular month how many weeks then it should display.

    2) If he select month then in that month how many days then it should display.

    Kindly find the attachment and in that what i require exactly output is there in the sheet.

    One of the first things you'll need to do is define what a "WEEK" is especially for the border weeks where the month changes.

    You need a Crosstab or Pivot to build the desired output. Because of the requirement to use any given month, it'll need to be dynamic SQL.

    I recommend the following articles to learn how to do this with very high performance... the first article teaches you how to do Crosstabs and Pivots (I strongly recommend the CrossTab method especially for the multi-column type output you require) and the second article teaches you how to do it dynamically.

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    http://www.sqlservercentral.com/articles/Crosstab/65048/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply