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 8423357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:42:11+00:00 2026-06-10T03:42:11+00:00

Consider a table such as this: CREATE TABLE records ( id INT NOT NULL

  • 0

Consider a table such as this:

CREATE TABLE records (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    eventOccured DATETIME NOT NULL,
    eventType INT NOT NULL,
    eventDescription VARCHAR(32)
)

I would like to retrieve the eventOccured and eventType fields from the entire table, but if two or more events occurred within an hour of each other then I would want only the first of them. This would be be simple if everything from N:00 to N:59 were considered the same hour, but in this case an event at 12:15 of eventType “5” would be considered to have occurred less than an hour after an 11:45 eventType “5”, and so should not be returned. Can this be done in MySQL without a stored procedure? I could write such a procedure, but I worry that it will be rather resource-intensive and I would love to learn if MySQL has such ability out of the box.

  • 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-06-10T03:42:12+00:00Added an answer on June 10, 2026 at 3:42 am

    What you are saying is that you want all events, where there is not another event in the next 60 minutes. This query does this in what should be a mysql friendly way:

    select *
    from records r
    where not exists (select 1
                      from records r2
                      where r2.eventOccured > r.eventOccured and
                            timestampdiff(minute, r.eventOccured, r2.eventOccured) < 60
                     ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider a fact table of the form: CREATE TABLE Fact1 ( Dim1 int NOT
Consider the following table which has the fields - id (int) and date_created (datetime):
Consider a table with the following schema: id, location, starred There are many records
Consider this table on SQL Server wordID aliasID value =========================== 0 0 'cat' 1
Consider a table or CTE structured like this: Name Num ---- ---- Abc 12
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5
I am trying to accomplish this: Consider a table view with Search Bar on
For the sake of the example, consider a table create table foo ( contents
I have a file containing a lot of SQL statements, such as: CREATE TABLE
Database software: SQLITE Consider this scenario: Table X has attributes: A,B,C,D,1,2,3,4 Table Y needs

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.