Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6349657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:39:30+00:00 2026-05-24T21:39:30+00:00

I have two tables for time dimension date (unique row for each day) time

  • 0

I have two tables for time dimension

date (unique row for each day)
time of the day (unique row for each minute in a day)

Given this schema what would a query look like if one wants to retrieve facts for last X hours where X can be any number greater than 0.

Things start to be become tricky when the start time and end time happen to be in two different days of the year.

EDIT: My Fact table does not have a time stamp column

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:39:31+00:00Added an answer on May 24, 2026 at 9:39 pm

    Fact tables do have (and should have) original timestamp in order to avoid weird by-time queries which happen over the boundary of a day. Weird means having some type of complicated date-time function in the WHERE clause.

    In most DWs these type of queries are very rare, but you seem to be streaming data into your DW and using it for reporting at the same time.

    So I would suggest:

    1. Introduce the full timestamp in the fact table.

    2. For the old records, re-create the timestamp from the Date and Time keys.

    DW queries are all about not having any functions in the WHERE clause, or if a function has to be used, make sure it is SARGABLE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have two tables with the following schema: CREATE TABLE sales_data ( sales_time date
I have two tables, both with start time and end time fields. I need
I have two tables, news and news_views. Every time an article is viewed, the
I have two tables which get updated at almost the exact same time -
I have two tables where column [date] is type of DATETIME2(0) . I have
i have 2 tables(result of two separate SQL queries and this result will be
I have two tables (1) MonthlyTarget {SalesManCode, TargetMonthYear, TargetValue}; this table has 1966177 rows.
I have two tables A and B Table A Name Time Price a 12/01/2011
I have two tables, Sales (ISBN, Sale_Time, [Sale Data Fields]) and Affiliate_Sales (ISBN, Affiliate_Sale-Time,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.