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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:18:59+00:00 2026-06-08T18:18:59+00:00

This is a query that I’ve been using: select serial_number, DAQ.qtag_no, min(TOH.start_time), order_number, DAQ.creation_time,

  • 0

This is a query that I’ve been using:

select serial_number, DAQ.qtag_no, min(TOH.start_time), order_number, DAQ.creation_time, qtag_status, ar_code, pro_foundin, pro_category, root_cause, remark from UNIT U 
left JOIN WORK_ORDER WO ON WO.order_key = U.order_key
left join TRACKED_OBJECT_HISTORY TOH on TOH.tobj_key = U.unit_key
WHERE U.creation_time > '01/01/2012' AND U.creation_time < '07/20/2012'
AND order_number NOT LIKE '[R]%' 
group by serial_number, qtag_no, order_number, DAQ.creation_time, qtag_status, ar_code, pro_foundin, pro_category, root_cause, remark
order by serial_number

Right now I get 3280 results.
In this setup, there are different stations, such as “Assembly,” “Diagnostics,” etc. My goal for the min(TOH.start_time) column is to return the first start time at the Assembly station, but currently it’s returning the first start time at ANY station. However, if I add another WHERE clause to specify the station (TOH.op_name = ‘Assembly’), it limits the number of results (down to 2700). I’d like to keep the 3280 results and instead for units not scanned in to the Assembly station, return NULL for min(TOH.start_time) column. I tried using the case function, but that requires me to include TOH.op_name in the group by clause, which I’m not looking for. Thanks!

  • 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-08T18:19:00+00:00Added an answer on June 8, 2026 at 6:19 pm

    You should just be able to add your condition to the left join I think, like this:

    select  serial_number, 
        DAQ.qtag_no, 
        min(TOH.start_time), 
        order_number, 
        DAQ.creation_time, 
        qtag_status, 
        ar_code, 
        pro_foundin, 
        pro_category, 
        root_cause, 
        remark 
    from UNIT U 
    left 
    JOIN    WORK_ORDER WO 
        ON  WO.order_key = U.order_key
    left 
    join    TRACKED_OBJECT_HISTORY TOH 
        on  TOH.tobj_key = U.unit_key
        and TOH.op_name = 'Assembly'
    WHERE   U.creation_time > '01/01/2012' AND U.creation_time < '07/20/2012'
    AND     order_number NOT LIKE '[R]%' 
    group by serial_number, qtag_no, order_number, DAQ.creation_time, qtag_status, ar_code, pro_foundin, pro_category, root_cause, remark
    order by serial_number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this MySQL query that I'd like to optimize: SELECT min(`topic_id`) FROM `gallery_topics`
I've got this query that works ok, select * from Materia where Cursar_Cursada=0 and
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have this query that inserts rows, using a subquery like so: INSERT INTO
I have this query that i've been trying to figure out how to convert
I have this query that works: select name, location_id from all_names where location_id in
I have this query that (stripped right down) goes something like this : SELECT
I have a query that goes like this: SELECT Product.local_price*Rate.exchange_rate AS 'US_price' FROM Product
I have a query that looks something like this: select xmlelement(rootNode, (case when XH.ID

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.