Friday 15 July 2011

SQL Server DW - Query data using Date dimension and Time Dimension -


Before the source system, I can do something like the following

  SELECT COUNT (* ) Forward Deductive FD Vair FD [Response_ts] '2013-01-01 45: 01: 38.000' and '2013-01-02 15: 04: 20.000'   

We now have a DW Where is a different date dimension ( Dim_Date ) and time dimension ( Dim_time ), I tried the query below but I can not find the same meaning < Pre> select COUNT (*) FACT_FlightDeparture Join FD within DIM_DATE DD Include FD.Resp_DATE_SK = DD.Date_Sk interiors on DIM_TIME tt FD.Resp_TIME_SK = TT.TIME_Sk and (DD.Cal_Date> = '2013-01-01' and TT.Time_Of_Day> = '14: 01: 38.000 ') and (DD.Cal_Date & lt; =' 2013-01-02 'and TT.Time_Of_Day & lt; = '14: 04: 20.000')

Please help me This issue has reduced how I am doing time partly

Thank you in advance

And the statement is preventing two predictions rarely coming back from the truth. Due to the difference of time_Of_Day, in fact, the situation can actually really come back within 3 minutes per day.

If I think that's right, then you need equal to 1/4 plus or 14:01:38 and at all times 1/2 or less 14:04:20 . / P>

  Select COUNT (*) FACT_FlightDeparture Join FD from within DIM_DATE FD.Resp_DATE_SK = DD.Date_Sk on DD Join DIM_TIME TT at FD.Resp_TIME_SK = TT.TIME_Sk Where ((DD. Cal_Date = '2013 -01-01' and T.Time_Of_Day> = '14: 01: 38.000 ') or (DD.CAL_DATE =' 2013-01-02 'and TT.time_Of_Day & lt; = '14: 04 : 20.000 '))   

If the fact sheet is large and you often plan to use this query pattern, then I put both of these columns into a single nonclusted index.

  Create responsive index IX_FACT_FlightDeparture_DateTime at FACT_FlightDeparture (Resp_DATE_SK, Resp_TIME_SK);   

In addition to this, do not forget about your partitioning, compression and other options if applicable.

No comments:

Post a Comment