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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:06:36+00:00 2026-05-30T17:06:36+00:00

Table Essentially looks like: Serial-ID, ID, Date, Data, Data, Data, etc. There can be

  • 0

Table Essentially looks like:

Serial-ID, ID, Date, Data, Data, Data, etc.

There can be Multiple Rows for the Same ID. I’d like to create a view of this table to be used in Reports that only shows the most recent entry for each ID. It should show all of the columns.

Can someone help me with the SQL select? 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-05-30T17:06:37+00:00Added an answer on May 30, 2026 at 5:06 pm

    There’s about 5 different ways to do this, but here’s one:

    SELECT *
    FROM yourTable AS T1 
    WHERE NOT EXISTS(
        SELECT *
        FROM yourTable AS T2
        WHERE T2.ID = T1.ID AND T2.Date > T1.Date
    )
    

    And here’s another:

    SELECT T1.*
    FROM yourTable AS T1
    LEFT JOIN yourTable AS T2 ON
    (
        T2.ID = T1.ID 
        AND T2.Date > T1.Date
    )
    WHERE T2.ID IS NULL
    

    One more:

    WITH T AS (
        SELECT *, ROW_NUMBER() OVER(PARTITION BY ID ORDER BY Date DESC) AS rn
        FROM yourTable
    )
    SELECT * FROM T WHERE rn = 1
    

    Ok, i’m getting carried away, here’s the last one I’ll post(for now):

    WITH T AS (
        SELECT ID, MAX(Date) AS latest_date
        FROM yourTable
        GROUP BY ID
    )
    SELECT yourTable.*
    FROM yourTable
    JOIN T ON T.ID = yourTable.ID AND T.latest_date = yourTable.Date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that essentially looks like this: CREATE TABLE myTable ( id
I have a database that essentially looks like this: id uniqueidentifier NOT NULL data
I have a table of data, that looks something like this: ID CODE 1
I have a table that looks basically like this: id | redirectid | data
I have a table populated with time stamped rows inserted at (essentially) random point
I have a table with rows like below id, name , phName , startDate,
I have a table that looks like this: Id (PK, int, not null) ReviewedBy
If I have a table that has data like: Test1 Test2 Test3 Test4 Test5
I have a column that looks like: Column A 1A 2B 5Z Essentially, I
I have a MySQL query that looks like this: UPDATE `Table` SET `Column` =

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.