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.
| Author |
Topic |
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-07-26 : 11:08:02
|
| I have a column in the table which represents a date 02/20/2011 and a trans id e.g.'2011021600000000000'I want group by week.e.g. I choose a start date Monday 4th July and then sum my transactional data by week 1, week 2, week 3 etc.Sorry if the confusion is slightly muddled thank you for reading and any help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-26 : 11:26:01
|
| [code]SELECT DATEPART(wk,CONVERT(datetime,LEFT(field,8),112)) ,SUM(Sales) AS TotalSalesFROM TableGROUP BY DATEPART(wk,CONVERT(datetime,LEFT(field,8),112))[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-07-26 : 11:38:46
|
| Looks good thanks a lot. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-26 : 11:45:20
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|