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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:08:12+00:00 2026-06-09T00:08:12+00:00

Preferably without downloading the entire database and scanning each item, is there a MySQL

  • 0

Preferably without downloading the entire database and scanning each item, is there a MySQL query that could access this table:

__________________________________
|   ColID   |      Timestamp      |
|___________|_____________________|
|_____2_____|_2012-08-01_12:00:00_|
|_____1_____|_2012-08-01_12:01:00_|
|_____3_____|_2012-08-01_12:02:00_|
|_____3_____|_2012-08-01_12:03:00_|
|_____2_____|_2012-08-01_12:04:00_|
|_____3_____|_2012-08-01_12:05:00_|

And return only these rows:

__________________________________
|   ColID   |      Timestamp      |
|___________|_____________________|
|_____1_____|_2012-08-01_12:01:00_|
|_____2_____|_2012-08-01_12:04:00_|
|_____3_____|_2012-08-01_12:05:00_|

So as to extract only one of each ColID with the highest Timestamp

  • 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-09T00:08:14+00:00Added an answer on June 9, 2026 at 12:08 am

    Use GROUP BY with MAX:

    SELECT   ColID, MAX(Timestamp) AS Timestamp
    FROM     tbl
    GROUP BY ColID
    

    Also, just a tip you may want to keep in mind for the future: if you wanted to also select other columns that might be in the same table for each maximum ColID, you cannot select it directly in the above query due to the nature of GROUP BY. You will need to wrap the query in a joined subselect joining on both the id and date columns:

    SELECT b.*
    FROM   tbl a
    JOIN   (
           SELECT   ColID, MAX(Timestamp) AS max_timestamp
           FROM     tbl
           GROUP BY ColID
           ) b ON a.ColID = b.ColID AND a.max_timestamp = b.Timestamp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a native way (preferably without implementing your own method) to check that
Preferably without using any kind of loop, as this'll be used in a game.
Is there any way to explicitly request vim to beep, preferably without having to
Is there a way (preferably without javascript) to prevent a TextBox control from overflowing
Is there a way to get the computer's physical position using Python, preferably without
What is the simplest (preferably without any new table creation) way of running a
What is the simplest way (preferably without using third party frameworks) in objective c,
I'd like to use Sendgrid WebAPI preferably without SMTP or Swiftmailer using the code
I want to get a MIME Content-Type from a given extension (preferably without accessing
My google-fu has failed me - can MonoDevelop be used on Windows? Preferably without

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.