Want to show eight week data

  • Hi All

    I want to show eight week data on my report with heading Week1....week8

  • It will be easier if you give table structure or columns from where to fetch data.

    Thanks

    Brij

  • I think by using CASE statement you can resolve the issue.

  • Great ....

    Many Thanks TK

     

  • It's not very clear what you're trying to do, but if you're aggregating data to get totals or just need to add a calculated week field into report data for display purposes, you can group by weeknumber using the datepart() function like this:

    DATEPART(wk, OrderDate)

    eg;

    select DATEPART(wk, OrderDate) , count(*) from orders GROUP BY DATEPART(wk, OrderDate)

    However, bear in mind that if you've got more than 1 years data, it just gives you the weeknumber irregardless of the year, so it'll total up the records from week 1 this year, plus week 1 the year before plus week 1 the year before that etc.

    I tend to add DATEPART(yy, OrderDate)  * 100 + DATEPART(wk, OrderDate)  to make an integer like this: 200601 and group and sort by that, and a corresponding varchar compound that looks like '2006 week 1'

     

Viewing 5 posts - 1 through 4 (of 4 total)

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