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

  • Home
  • SEARCH
  • 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 6606311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:22:57+00:00 2026-05-25T19:22:57+00:00

I have three tables, one is tasks which are tasks that factory workers complete

  • 0

I have three tables, one is tasks which are tasks that factory workers complete by putting them into batches, which is another table, each task has a batch_id, multiple tasks can have the same batch_id. The third table is the batch_log where all time that someone has worked on a batch is recorded in the form of a unique id, a batch_id, the person’s userid, the start_time and the end_time.

Each task has an estimated_recurring time in seconds and an estimated_nonrecurring time in seconds. I’m looking to get the sum of both of those fields grouped by the operation_id which is a field in the tasks table to represent whether it is a laser cutting, deburr, painting, etc task.

The issue is that I only want the tasks that have batches that were in the batch_log during a time_period. Batches have multiple entries in the batch_log table.

Here is what I’m trying:

SELECT 
  operation_id, SUM(t.estimated_nonrecurring + t.estimated_recurring) / 3600 as work_completed
FROM tasks t
INNER JOIN batch_log l on t.batch_id = l.batch_id
WHERE 
  l.start_time BETWEEN DATE("10:00:00") AND DATE(NOW())
AND
  l.time_elapsed < "10:00:00"
GROUP BY t.operation_id

I’m concerned that I will get a higher estimate than is real because multiple entries in the task table can have the same batch.

  • 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-25T19:22:57+00:00Added an answer on May 25, 2026 at 7:22 pm

    Because you only want the times based on tasks that were in your batch log file what you posted will definately not work.

    Assuming you have 3 tables: Tasks, Batches, and BatchLog.

    You’ll want this:

    SELECT
          SUM(t.estimated_nonrecurring + t.estimated_recurring) / 3600 as work_completed,
          t.OperationID
    FROM
          Tasks t
    INNER JOIN
           Batches b
    ON
           b.BatchID = t.BatchID
    INNER JOIN
           BatchLog bl
    ON
           bl.BatchID = b.BatchID
    WHERE  
      bl.start_time BETWEEN DATE("2011-08-01") AND DATE(NOW())
    GROUP BY
           t.OperationID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which needs to link one of three seperate tables, but
I have two tables one has a three column composite key. The other needs
I have a logging table which has three columns. One column is a unique
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I have two tables (Tasks and Timeentries), which are connected by a foreign key
I have a table column where each row has one of three states, and
I have a composite index on three column in one of my table. It
I have two product tables Product1 and Product2. There is a one 2 one
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page

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.