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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:48:46+00:00 2026-05-25T17:48:46+00:00

I will revise the question with an appropriate name once I’m certain how to

  • 0

I will revise the question with an appropriate name once I’m certain how to communicate what I want.

I have a table called batch_log where people start and stop the work on a batch. Each entry looks like this:

"id";"batch_id";"userid";"start_time";"end_time";"time_elapsed"
"99980";"cd9e4c9e-d8bb-4983-64f4-4e777b451b93";"phastie";"2011-09-22 08:54:34";"2011-09-22 10:07:07";"01:12:33"

What I really want to do is for a particular person select how long they have tracked compared to the total time for that batch so that I can give them credit for that much of the estimated time. Is there a way to do this in sql?

EDIT[Ended up doing the following:]

SELECT user_time_by_batch.batch_id, userid, user_time_by_batch / total_time_by_batch FROM
(
  SELECT SUM(time_elapsed) user_time_by_batch, userid, batch_id
  FROM batch_log
  Where start_time between "2011-08-01" and now()
  and end_time is not null and time_elapsed BETWEEN "00:00:00" AND "10:00:00"
    and batch_id not in ("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-10", "-11", "-12", "-13")
  GROUP BY batch_id, userid
) user_time_by_batch
INNER JOIN 
(
  SELECT SUM(time_elapsed) total_time_by_batch, batch_id
  FROM batch_log
  Where start_time between "2011-08-01" and now() 
    and end_time is not null and time_elapsed BETWEEN "00:00:00" AND "10:00:00"
    and batch_id not in ("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-10", "-11", "-12", "-13")

  GROUP BY batch_id
) total_time_by_batch
ON user_time_by_batch.batch_id = total_time_by_batch.batch_id
  • 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-25T17:48:47+00:00Added an answer on May 25, 2026 at 5:48 pm

    This should give you what you need

    
    SELECT user_id, user_time_by_batch / total_time_by_batch FROM
    (
      SELECT SUM(time_elapsed) user_time_by_batch, user_id, batch_id
      FROM batch_log
      GROUP BY batch_id, user_id
    ) user_time_by_batch
    INNER JOIN 
    (
      SELECT SUM(time_elapsed) total_time_by_batch, batch_id
      FROM batch_log
      GROUP BY batch_id
    ) total_time_by_batch
    ON user_time_by_batch.batch_id = total_time_by_batch.batch_id
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Will there be any further resultset to process if the lookup table in the
REVISED QUESTION I realize using the response to: $facebook->api('/me?access_token='.$access_token) will determine whether you need
MAJOR EDIT: Problem was solved after reading Will Dean's comment. The original question is
I have several methods in the ListAC ListActivity that I want to reuse and
I have an input box whose id is sellingprice . i want to check
My last quest was too vague, so I will revise it. I know the
Will Java code built and compiled against a 32-bit JDK into 32-bit byte code
Will GHC perform tail-call optimization on the following function by default? The only weird
Will it be possible for windows xp or windows server 2003 to support net.tcp
Will this code ever wait on the mutex inside the producer's void push(data) ?

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.