Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

time range dimention based on a number Expand / Collapse
Author
Message
Posted Thursday, August 29, 2013 7:33 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 6:44 AM
Points: 286, Visits: 573
Hi

I would like to create a time range dimention based on a numerical value.


so I have a column in my fact table that represents the number of years and I would like the dimention to group the clumns to say <1 year, 1-2 years, 3-5 years, 6-10 years, etc

is the only way to do this to create another table with a number field and a group field (as below)?


Year Group

0 <1 year

1 1-2 years

2 1-2 years

3 3-5 years

4 3-5 years

5 3-5 years

6 6-10 years

thanks in advance
Post #1489718
Posted Thursday, August 29, 2013 9:21 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 4:20 PM
Points: 35,265, Visits: 31,755
No. You could add a computed column for this. I recommend it be a persisted computed column to make it faster.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1489988
Posted Friday, August 30, 2013 8:21 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 7:02 AM
Points: 817, Visits: 2,048
I recommend a table that is then turned into a dimension. It will give you more flexibility to add/change things.


Post #1490181
Posted Friday, August 30, 2013 8:30 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 6:44 AM
Points: 286, Visits: 573
thanks a lot fellas, I understand the process now
Post #1490184
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse