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 |
|
whitegrs
Starting Member
5 Posts |
Posted - 2009-11-27 : 12:16:26
|
| Hello AllI have a BI project that I am working on.I need to categorize data into week numbers and quarters. The problem is this: Some WeekNos fall across 2 quarters :Example: records in the 27th week of the year (200927) fall into the second quarter and the third quarter: becuase week starts 29/6/2009 - 04/07/2009.The problems is showing up as duplicated results in the queries.Any Ideas?Thanks |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2009-11-27 : 12:23:39
|
| define a table with 1 record per day.1/1/2009 q12/1/2009 q13/1/2009 q1etc29/6/2009 q230/6/2009 q2etc04/7/2009 q3or apply a formula to the month number... quarter = floor(month/3) |
 |
|
|
whitegrs
Starting Member
5 Posts |
Posted - 2009-11-27 : 12:26:45
|
| Thanks for the reply I cant use Floor(month) becuase it crosses 2 months.I also cant use a caledar table becuase the client doesnt want to maintain a table |
 |
|
|
whitegrs
Starting Member
5 Posts |
Posted - 2009-11-27 : 12:29:16
|
| Also, Im using indexed aggregated views so I cant use a CASE statement in the indexed view. |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2009-11-30 : 05:40:14
|
| a) find something that worksb) find something that works better.At the moment you seem to be rejecting options that satisfy a). Good luck in the search. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-11-30 : 07:10:55
|
What's wrong with:SELECT DATEPART(QUARTER,[yourDate])SELECT DATEPART(WEEK, [yourDate]) Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|