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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:03:26+00:00 2026-05-16T00:03:26+00:00

heres a table, the time when the query runs i.e now is 2010-07-30 22:41:14

  • 0

heres a table, the time when the query runs i.e now is 2010-07-30 22:41:14

number | person | timestamp
45       mike     2008-02-15 15:31:14
56       mike     2008-02-15 15:30:56
67       mike     2008-02-17 13:31:14
34       mike     2010-07-30 22:31:14
56       bob      2009-07-30 22:37:14
67       bob      2009-07-30 22:37:14
22       tom      2010-07-30 22:37:14
78       fred     2010-07-30 22:37:14

Id like a query that can add up the number for each person. Then only display the name totals which have a recent entry say last 60 minutes. The difficult seems to be, that although its possible to use AND timestamp > now( ) – INTERVAL 600, this has the affect of stopping the full sum of the number.

the results I would from above are

Mike 202
tom  22
fred 78

bob is not included his latest entry is not recent enough its a year old! mike although he has several old entries is valid because he has one entry recently – but key, it still adds up his full ‘number’ and not just those with the time period.

go on get your head round that one in a single query ! and thanks

andy.

  • 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-16T00:03:27+00:00Added an answer on May 16, 2026 at 12:03 am

    You want a HAVING clause:

    select name, sum(number), max(timestamp_column)
    from table
    group by name
    HAVING max( timestamp_column) > now( ) - INTERVAL 600;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select Info by timestamp and UnitID. Heres the two tables: Table
A particular UPDATE query on our website sometimes runs extremely slow, and examines a
I have a PHP script that runs a SELECT query then immediately deletes the
I have a table with a DATE column with time (as usual in Oracle
I have the below query... It works but it runs extremely slow. Was hoping
I'm writing a query into a table that keeps track of a salesman's status,
I have a large table with 1 million+ records. Unfortunately, the person who created
I have a temperature measurements stored in a table, each measure have actuall date/time
I have a stored procedure running on sql server 2008 looping over a table
i am working in winforms with C#. heres my code query = SELECT max(Appointment_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.