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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:22:09+00:00 2026-05-27T09:22:09+00:00

I have a table (table1): ID INSERTDATE ISSUE SOURCE 1 2011-12-01 A EMAIL 2

  • 0

I have a table (table1):

ID   INSERTDATE    ISSUE    SOURCE
1    2011-12-01    A        EMAIL
2    2011-12-02    B        POST
3    2011-12-03    C        MEETING
4    2011-12-04    B        INTERNET

I would like to get the latest SOURCE for each issue…

SELECT * FROM table1 GROUP BY SOURCE ORDER BY ISSUE ASC

Results in

ID   INSERTDATE    ISSUE    SOURCE
1    2011-12-01    A        EMAIL
2    2011-12-02    B        POST
3    2011-12-03    C        MEETING

But how can I get the following, so that issue B has the latest source?

ID   INSERTDATE    ISSUE    SOURCE
1    2011-12-01    A        EMAIL
4    2011-12-04    B        INTERNET
3    2011-12-03    C        MEETING
  • 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-27T09:22:09+00:00Added an answer on May 27, 2026 at 9:22 am

    You need an aggregate and a self join.
    This is standard SQL without relying on the MySQL group by extensions (which are rubbish)

    SELECT
        t.*
    FROM
        ( -- get most recent ID per issue
        SELECT MAX(ID) AS MaxID, ISSUE
        FROM table1
        GROUP BY ISSUE
        ) t2
        JOIN  -- join back to get the whole row
        table1 t ON t2.MaxID = t.ID
    

    Edit, after comment. Assumes one change per day only

    SELECT
        t.*
    FROM
        ( -- get most recent INSERTDATE per issue
        SELECT MAX(INSERTDATE) AS MaxINSERTDATE, ISSUE
        FROM table1
        GROUP BY ISSUE
        ) t2
        JOIN  -- join back to get the whole row
        table1 t ON t2.MaxINSERTDATE = t.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table Table1 . With fields f1, f2 The table values are like
i have table called table1 and it looks like the below record type tran_ref_number
We have a table called table1 ... (c1 int indentity,c2 datetime not null,c3 varchar(50)
I have created one table using the below command: create table Table1( Id int
I'm way out of my league here... I have a mapping table (table1) to
I have a table with the following Table1 col1 col2 ------------ 1 A 2
I have a table in a div , with IDs of table1 and div1
In a table I have the following schema table1: playerID int primary key, nationalities
I have a simple table (lets call it Table1) that has a NVARCHAR field
Suppose I have database table TABLE1 and there is Column COLUMN1 . The variable

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.