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

  • SEARCH
  • Home
  • 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 6080629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:05:00+00:00 2026-05-23T11:05:00+00:00

I denormalized my data (so a date is split up in a year, month,

  • 0

I denormalized my data (so a date is split up in a year, month, day and hour column)
But now I wonder how to query everything before a certain date.

This does NOT work:

SELECT * 
FROM  `impression_stat_hour` 
WHERE doneforday =0
AND (
    YEAR <=2011
    AND MONTH <=6
    AND DAY <=30
    AND HOUR <=1
)

This won’t actually “group” all the records together as I want them too, resulting in date that is (for example) always from hour 0 and hour 1.

  • 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-23T11:05:01+00:00Added an answer on May 23, 2026 at 11:05 am
    SELECT ...
    WHERE
        YEAR < 2011
        OR (YEAR = 2011 AND MONTH < 6)
        OR (YEAR = 2011 AND MONTH = 6 AND DAY < 30)
        OR (YEAR = 2011 AND MONTH = 6 AND DAY = 30 AND HOUR <= 1)
    

    Or:

    SELECT ...
    WHERE STR_TO_DATE(CONCAT(year,'-',month,'-',day,' ',hour,':00:00')) <= '2011-06-30 01:00:00';
    

    The latter is probably a lot slower (since it can’t use indexes on your various date columns. It’s also untested, since the only (ancient) version of MySQL I have access to doesn’t support STR_TO_DATE().

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

Sidebar

Related Questions

In reporting tools like Crystal Reports, there are ways to take denormalized data and
I know, think in denormalized way or nosql way. but tell me about this
I've created a denormalized table that needs to be inserted/updated every hour. The process
I have denormalized data (coming from a file) that needs to be imported into
We have a data warehouse with denormalized tables ranging from 500K to 6+ million
I have a large table(60 columns, 1.5 million records) of denormalized data in MS
I have three denormalized tables that I have to take at face value (data
I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code
We've designed our Mongo database to be highly denormalized, resulting in many documents in
!!! WARNING !!! Dearest SQL expert, please keep reading before to start to scream.

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.