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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:36:04+00:00 2026-05-23T08:36:04+00:00

I have a table which is randomly generated. It has 3 columns : P_Id,

  • 0

I have a table which is randomly generated. It has 3 columns : P_Id, date (at which the row was inserted) and text. Let’s say the text can be various animals. So the table could look like

1      2011-06-15 03:04:05    cow  
2      2011-06-15 03:04:15    dog  
3      2011-06-15 03:04:19    bird  
4      2011-06-15 03:04:30    cow  
5      2011-06-15 03:04:30    dog  
6      2011-06-15 03:04:35    cow  
....  

What is a query to pick all animals that have occurred at least twice within the last 30 minutes of its latest entry? For eg, here cow occurs 3 times within the last 30 minutes of its latest entry, which is at 3:04:35, and dog has occurred twice. Bird would not be selected as it only occurred once.

  • 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-23T08:36:04+00:00Added an answer on May 23, 2026 at 8:36 am

    There’s always the straight forward way (i.e. use a subquery to extract the timestamp range and then proceed as usual):

    select name, count(name)
    from your_table
    where created_at >= (
        select max(created_at) - INTERVAL 30 MINUTE
        from your_table
    )
    group by name
    having count(name) >= 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DB table in which each row has a randomly generated primary
Let's say I have a Blog posts table that has a rating field which
I have a table y Which has two columns a and b Entries are:
In a SQL server database, I have a table which contains a TEXT field
I have a randomly generated link id which is 8 digits long with 50
I have table which class is forum . My jquery code: <script type=text/javascript> $(document).ready(function()
I have table which has a class data and it has table rows inside
I have a table which has following fields project_name VARCHAR (100) running_frequency enum ('daily',
I have a table which contains contact information. This table has 1 column relevant
I have a table which have an integer coloumn. Let table name is Table1

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.