Reports for across last 4 weeks,3 weeks,2 weeks

  • Hi,

    Hi,

    Please find the attachment and tell how to write query for genrating reports like that.

    I am using below query to genrate reports

    My reports should be for across last 4 weeks,3 weeks,2 weeks,1st week,2nd ,3rd,4th week.

    With the below query i am able genrate reports for 1st week,2nd week,3rd week and 4th week.

    Tell me how to generate reports for across last 4 weeks,3,2.

    Across last 4 weeks includes Reports for all weeks combining

    Declare @TotalEmployee int

    Select @TotalEmployee=4

    SELECT weekstartdate,

    convert(varchar,dbo.FDiv(Count(Case When delta='0' Then EmpNo end),@TotalEmployee)*100)+'%' as 'No Delta',

    convert(varchar,dbo.FDiv(Count(Case when delta>'0' and delta<='2' Then EmpNo end),@TotalEmployee)*100)+'%' as 'Within 2hrs',

    convert(varchar,dbo.FDiv(Count(Case when delta>'2' Then EmpNo end),@TotalEmployee)*100)+'%' as 'Greater than 2'

    FROM Test1

    GROUP BY weekstartdate

  • I'm not entirely clear what you want, but there is a parameter for datepart that can give you the week of the year. You could include that in your query and then group/break by that value.

  • Hi,

    Please find the attachment.How to genrate reports like that.

    I have 4 weeks data based on this i need to generate reports for across last 4,3,2 weeks,1st,2nd,3rd,4th week.

    Just give stored procedure structure on how to do that.

  • naresh0407 93367 (10/7/2010)


    Just give stored procedure structure on how to do that.

    Fair warning and a bit of friendly advise... people are going to take strong exception to a written attitude like that whether you mean it the wrong way or not. I recommend you take a look at the first link in my signature line below and format your question in that manner to actually get help on this particular problem.

    --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 4 posts - 1 through 3 (of 3 total)

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