Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Group by Weeks with in a date range

Author  Topic 

blackX
Posting Yak Master

102 Posts

Posted - 2008-12-10 : 11:30:50
I need to see summary detail information but I dont want to ask for each specific week. This will be for a report in Crystal. Our week go from Tueday thru Monday. Basically I would supply a procedure with a start and end date and I would see the summary for each week. Can anyone give me anything to get me started?

So if I supply the dates 11/25/2008 and 12/8/2008 I would something like

11/25/2008 thru 12/1/2008
Net Sales: 512,000 Deals sold: 65

12/2/2008 thru 12/8/2008
Net Sales: 482,000 Deals sold: 57

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-10 : 12:04:06
[code]SELECT DATEADD(wk,DATEDIFF(wk,0,datefield),0)+1,
SUM(Salesfieldhere),
COUNT(dealfieldhere)
FROM Table
WHERE datefield BETWEEN @Start AND @End+1
GROUP BY DATEADD(wk,DATEDIFF(wk,0,datefield),0)+1[/code]
Go to Top of Page
   

- Advertisement -