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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:47:19+00:00 2026-05-29T11:47:19+00:00

I can only describe the question by example.. If I have this data use-id

  • 0

I can only describe the question by example..
If I have this data

    use-id         user-name          add-date
---------------------------------------------------
    2              sami               17/1/2011
    2              sami               18/1/2011
    3              alaa               18/1/2011
    4              jamal              19/1/2011

I want to select the newest row for each user, I want this data to result :

    use-id         user-name          add-date
---------------------------------------------------
    2              sami               18/1/2011
    3              alaa               18/1/2011
    4              jamal              19/1/2011

for each unique user-id I want to get the newsest added record. how ?

  • 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-29T11:47:20+00:00Added an answer on May 29, 2026 at 11:47 am

    One way is to get the date of the newest record for each user:

    select `use-id`, max(`add-date`) as `latest` 
    from <table_name> 
    group by `use-id`
    

    We’ll call that query newest_records, and use it to select only those rows that have the latest date:

    select a.*
    from <table_name>
    inner join newest_records b
    on a.`use-id` = b.`use-id` and a.`add-date` = b.`latest`
    

    Edit:

    Putting it all together (copy/paste), we have:

    select a.*
    from <table_name>
    inner join (  
      select `use-id`, max(`add-date`) as `latest` 
      from <table_name> 
      group by `use-id`) b
    on a.`use-id` = b.`use-id` and a.`add-date` = b.`latest`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to perform what I can only describe as the reverse version
I can only assume this is a bug. The first assert passes while the
Since arrays and hashes can only contain scalars in Perl, why do you have
Hello everyone I have a question that I will describe as good as I
I'm not sure how to describe this problem, so I think an example is
I have started a bounty for this question ...because I really want the community's
I have a table that contains partial data that is of no use to
Follow up question to: This question As described in the linked question, we have
ReWrite: I have stripped the question down to contain the example code instead of
I can only think of Peek() and ReadNoAdvance() atm, but I wonder if there

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.