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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:40:29+00:00 2026-06-11T13:40:29+00:00

I have a table of data as follows id status conversation_id message_id date_created 1

  • 0

I have a table of data as follows

id    status    conversation_id    message_id    date_created
1     1         1                  72            2012-01-01 00:00:00
2     2         1                  87            2012-03-03 00:00:00
3     2         2                  95            2012-05-05 00:00:00

I want to get all the rows from the table in date_created DESC order, but only one row per conversation_id. So in the case of the example data above, I would want to get the rows with id 2 and 3.

Any advice is much appreciated.

  • 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-11T13:40:31+00:00Added an answer on June 11, 2026 at 1:40 pm

    See SQL Fiddle

    SELECT T.*
    FROM T
    WHERE NOT EXISTS (
      SELECT * 
      FROM T AS _T
      WHERE _T.conversation_id = T.conversation_id
      AND (
        _T.date_created > T.date_created
        OR
        _T.date_created = T.date_created AND _T.id > T.id) 
    )
    ORDER BY T.date_created DESC
    

    gets

    ID      STATUS  CONVERSATION_ID   MESSAGE_ID    DATE_CREATED
    3         2         2                95         May, 05 2012 
    2         2         1                87         March, 03 2012 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table of data that is sorted as follows: Item | Sample |
I have a table of data with survey results, and I want to do
My JavaScript is as follows: $.get(/<page>.php, userid='.$userid.'&+status, function(data){ $(#status).show(fast).html(data).delay(4000).hide(fast); }); I have many links
I have a table of data as follows: t1 ____________________________________________________ resources | companyName |
I have a table table_a with a column containing data as follows: .aaa01932 .asd02343
i have a php code which selects and shows data from my 'elections' table.
My scenario is as follows: I have a table of data (handful of fields,
I have a table of data that may look as follows. Answers are always
Hi all I am having my data table which is from my database is
I have a data table as follows ID Key Value -------------------------- 1 F1 2

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.