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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:36:20+00:00 2026-05-27T15:36:20+00:00

I use this query below to get the latest Serial Number that has been

  • 0

I use this query below to get the latest Serial Number that has been added

SELECT 
    SerialNo, 
    MAX(AddDate) AS AddDate
FROM 
    tst_EquipmentItem 
WHERE 
    ControlNo = 'TM-00012'
GROUP BY 
    SerialNo
ORDER BY 
    AddDate
OUTPUT:
SerialNo////AddDate
=======================================
TM-00012////2008-08-05 10:25:00.000

Now in the tst_Equipment table there is a ControlNo column. If I include ControlNo to the above statement I get a different output

OUTPUT
SerialNo///ControlNo///AddDate
====================================================
TM-00012///TM-CGI-F-0027///2004-02-09 08:20:00.000
TM-00012///TM-EN-N-0068///2008-08-05 10:25:00.000

How do I include the ControlNo column without having to put it in the GROUP BY Clause so that I can get the latest ControlNo for each SerialNo?

  • 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-27T15:36:20+00:00Added an answer on May 27, 2026 at 3:36 pm

    Without knowing your data, I would do:

    select distinct t.serialNo, e.controlNo, t.addDate
    from tst_EquipmentItem e
    join (
        select serialNo, max(addDate) as addDate
        from tst_EquipmentItem 
        group by serialNo
    ) t on t.serialNo = e.serialNo and t.addDate = e.addDate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The answer to another SO question was to use this SQL query: SELECT o.Id,
I use the query below to get the next item of a specific type
if i use this query thath creates a table(look Table1), But VisitingGap column is
I am trying to use this MySQL query: SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1
Related to: Query Windows Search from Java But this time to use OSX's spotlight
This is very confusing, I use AsDataView to bind query result to a dgv
I know in an actual query, you can use auto_increment=1 but how is this
use this website a lot but first time posting. My program creates a number
I have been on this mysql query for 2 days running. This is the
I'm wondering the following, the query below will select the appropriate fields if a

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.