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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:10:11+00:00 2026-05-26T05:10:11+00:00

I have the following table: Record ID Status Date Timestamp ———————————————————- 1 1 waiting

  • 0

I have the following table:

Record   ID   Status     Date          Timestamp
----------------------------------------------------------
1        1    waiting    2010-02-02    2010-02-02 12:00:00
2        1    finished   2010-02-02    2010-02-02 12:30:00
3        2    waiting    2009-02-02    2009-02-02 12:00:00

I want to get the records where Date is between 2010-01-01 and 2010-03-03.
(this should give me Records 1 and 2)

Further I want to get only the latest (having most recent timestamp) for each ID.
(this should give me Record 2 only).

I am not sure how I need to structure my query. I have managed to build the following query:

SELECT   `Record` `ID`, MAX(  `Timestamp` ) 
FROM     `myTable` 
WHERE    `Date` 
BETWEEN  '2010-01-01'
AND      '2011-03-03'
GROUP BY `ID` 

The problem with the above query is that for some reason it is giving me the following result:

Record   ID   Timestamp
---------------------------------
1        1    2010-02-02 12:30:00

which is correct except that the Record field should have the value 2 and not 1.

  • 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-26T05:10:11+00:00Added an answer on May 26, 2026 at 5:10 am
    SELECT t1.* 
    FROM `myTable` t1
    INNER JOIN
    (
    SELECT MAX(`Timestamp`) as Timestamp
    FROM     `myTable`
    WHERE    `Date` 
    BETWEEN  '2010-01-01'
    AND      '2011-03-03'
    GROUP BY `ID` 
    ) t2
    ON t1.Timestamp = t2.Timestamp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a the following table ItemStatus ---------- id item_id status I want to
I have a table by the following structure and records, All i want to
Simply I have the following table with records , i want to return randomly
I have the following transaction: SQL inserts a 1 new record into a table
I have the following table. When i try to insert records using LINQ to
I have the following table: //table_1 record_id user_id plant_id date cost 1 1 1
Suppose I have the following MySQL table: user_id date_of_application date_ended grade status --------------------------------------------------------------- 1
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have the following table relationship in my database: Parent / \ Child1 Child2

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.