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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:30:15+00:00 2026-05-23T09:30:15+00:00

If I have records in a table that are timestamped how do I query

  • 0

If I have records in a table that are timestamped how do I query so that I get the results for each day for each user as a row in the resultset along with additional info from another table?

Example:

batch_log

id  |  userid | batchid | start_time         | end_time            |time_elapsed
----------------------------------------------------------------------------------
1   |  bob    | 123sgd  |2011-06-23 18:00:00 | 2011-06-23 18:12:00 | 00:12:00
2   |  jim    | 234sgd  |2011-06-22 12:00:00 | 2011-06-22 12:12:00 | 00:12:00
3   |  bob    | 1234gd  |2011-06-23 19:00:00 | 2011-06-23 19:08:00 | 00:08:00
4   |  bob    | 1Abeds  |2011-06-22 19:00:00 | 2011-06-23 20:24:00 | 00:24:00

screwups

id  |  userid | time_of_screwup
---------------------------------------------
1   |  bob    |2011-06-23 19:29:16 
2   |  jim    |2011-06-23 16:29:24
3   |  bob    |2011-06-22 12:29:16 
4   |  bob    |2011-06-23 13:29:16 

How do I select so that I can get both the time elapsed and the number of screwups daily for each person so that I can feed this into excel.

Example output:

  userid | date       |COUNT(time_elapsed)| COUNT(screwups)|
------------------------------------------------------------
  bob    | 2011-06-23 | 00:20:00          |   2
  jim    | 2011-06-22 | 00:12:00          |   1
  bob    | 2011-06-22 | 00:24:00          |   1

EDIT: Data that makes more sense

  • 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-23T09:30:15+00:00Added an answer on May 23, 2026 at 9:30 am

    Having an id field on your results doesn’t really make sense, so I’ll just ignore that that field exists. Similarly, I doubt that time_elapsed will be the same for different job runs on the same day, so we’ll knock that out.

    Getting rid of those two fields leaves us with a fairly straightforward GROUP BY query. I don’t know the specifics of your database so, for the purposes of this problem, I’ll assume that your DB has a DATE() function that returns the date part of a timestamp. Unless you left out important details in your question , the existence of the batch_log table is a red herring. You really just want to SELECT userid, DATE(time_of_screwup), count(*) FROM screwups GROUP BY userid, DATE(time_of_screwup).

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

Sidebar

Related Questions

I have one table that has sales records and another table that has additional
I have a table that has about 1/2 million records in it. Each month
I have table that records logins for users. I'm having trouble finding a query
I have about 40000 records in that table that contains plain text and within
I have a table that records a sequence of actions with a field that
I have a table that has 8 million records, with many fields, including lat/long
I have a table that has records with a structure similar to this.. ID
I have a table that has millions of records and we are looking at
I have an application that records activity in a table (Oracle 10g). The logging
I have a table within my database that has many records, some records share

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.