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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:56:10+00:00 2026-06-09T12:56:10+00:00

This is my current query: select serial_number, order_number, (select TOP 1 PRODUCT_ID from PS_ORD_LINE

  • 0

This is my current query:

select serial_number, order_number,
(select TOP 1 PRODUCT_ID from PS_ORD_LINE PL 
where PL.ORDER_NO = WO.order_number 
and CAT_DESCR = 'SYSTEM' and ORD_LINE_STATUS = 'O' 
ORDER BY ORDER_INT_LINE_NO) as model,
(select datediff(minute, min(complete_time), min(start_time)) 
 from TRACKED_OBJECT_HISTORY TOH1 
 where TOH1.op_name IN ('Assembly', 'Pre-Final') 
 and TOH1.tobj_key = TOH.tobj_key) as waiting_time1,
from UNIT U
left join WORK_ORDER WO on U.order_key = WO.order_key
left join TRACKED_OBJECT_HISTORY TOH on TOH.tobj_key = U.unit_key
where WO.creation_time > '5/1/12' and WO.creation_time < '7/31/12'
group by serial_number, order_number, tobj_key

The part in the middle with DateDiff is my problem.

So Assembly and Pre-Final are the names of two different stations that units are scanned in. Assembly is usually first in line, followed immediately by Pre-Final.

What I’m trying to do is to calculate the elapsed time after a unit scans out of Assembly and before that unit scans into Pre-Final. complete_time marks when a unit is scanned out of a station, and start_time is when it’s scanned in.

Right now, my query doesn’t work because both start_time and complete_time refer to Assembly because it’s the first station. However, I want complete_time to refer to Assembly while I want start_time to refer to Pre-Final.

How should I go about doing this?

  • 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-06-09T12:56:11+00:00Added an answer on June 9, 2026 at 12:56 pm

    Perhaps using

    DATEDIFF(MINUTE,
             (SELECT MIN(complete_time)
                FROM TRACKED_OBJECT_HISTORY toh1 
                WHERE toh1.op_name = 'Pre-Final' AND toh1.tobj_key = toh.tobj_key),
             (SELECT MIN(start_time) 
                FROM TRACKED_OBJECT_HISTORY toh2
                WHERE toh2.op_name = 'Assembly' AND toh2.tobj_key = toh.tobj_key)
             ) AS waiting_time1,
    

    etc.

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

Sidebar

Related Questions

This is my current query: $sel = SELECT db1t1.userid, db1t1.customer_id, db2t1.customers_id, db2t1.orders_id, db2t2.products_price FROM
This is my current query: SELECT DISTINCT t.* FROM filter AS f INNER JOIN
with my current query and loop: $sched = mysql_query(SELECT * FROM `shows` ORDER BY
My current query: SELECT * FROM `reported_users` GROUP BY `reported_user` ORDER BY ??? I
This is my current query: SELECT * FROM users WHERE blah blah... AND users.who
My Current query is: SELECT DISTINCT DATE(vote_timestamp) AS Date, COUNT(*) AS TotalVotes FROM `votes`
My current query: SELECT Series.*, Episodes.* FROM Series, Episodes WHERE EpisodeAirDate > '.time().' AND
Current query SELECT * FROM employee AS E INNER JOIN credential AS C ON
My current query:- select p.id as product_id, p.product_name, child.name as category_name, parent.name as parent_category_name
I have this query: SELECT v2.longitude AS something FROM points AS v2 Now I

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.