September 11, 2014 at 6:46 am
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.
September 11, 2014 at 8:49 am
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
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply