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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:26:24+00:00 2026-05-29T08:26:24+00:00

I have a table something like this: —————————————- |uID|responseDate|field_01|field_02|etc| +—+————+——–+——–+—+ | 1 | 2011-12-02

  • 0

I have a table something like this:

----------------------------------------
|uID|responseDate|field_01|field_02|etc|
+---+------------+--------+--------+---+
| 1 | 2011-12-02 |   yes  |    no  |   |
| 2 | 2011-11-25 |   no   |   yes  |   |
| 1 | 2012-01-02 |   no   |   yes  |   |
| 2 | 2012-12-01 |   no   |    no  |   |
| 3 | 2010-01-02 |   yes  |    no  |   |
+---+------------+--------+--------+---+

I would like to get uIDs and responseDates for whom the latest response to field_01 is ‘yes’ – so my query should return:

------------------
|uID|responseDate|
+---+------------+
| 3 | 2010-01-02 |
+---+------------+

I’m using an inner join, but incorrectly. Here is my query:

SELECT f.uID, f.responseDate
FROM form_05 as f
INNER JOIN (
    SELECT uID, max(responseDate) AS latest_date
    FROM form_05
    WHERE field_01 = 'yes'
    GROUP BY uID ) dmax
 ON dmax.uID = f.uID and dmax.latest_date = f.responseDate
 ORDER BY f.uID ASC;

What this returns, however, is the latest entries for each uID where field_01 is yes, i.e.:

------------------
|uID|responseDate|
+---+------------+
| 1 | 2011-12-02 | 
| 3 | 2010-01-02 |
+---+------------+    

But I don’t want that. I’d like to make it so that only the latest entry for each uID is eligible for the test. How can I restructure the query? Any pointers are greatly 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-05-29T08:26:25+00:00Added an answer on May 29, 2026 at 8:26 am

    Give this a try and let me know if it doesn’t work:

    select t2.uid, t2.responseDate from t2
    left join (
        select t1.uid, max(t1.responseDate) as MaxDate from t1
        group by t1.uid
    ) as SubQuery on t2.uid = SubQuery.uid and t2.responseDate = SubQuery.MaxDate
    where MaxDate is not null and field_01 = "yes"
    
    • 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 looks something like this: word big expensive smart fast
I have a table that looks something like this: id | firstperson | secondperson
I currently have a table structure that looks something like this(some details omitted): ColumnName
Let's say I have a MySQL table that is something like this: software table:
I have something like this: create table account ( id int identity(1,1) primary key,
I have two tables which looks something like this Table Queue int ID; string
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have a table say something like this: column_a column_b foo 1 bar 1
I Have a table that looks something like this: ComputerID | Free_Space | Disk_Size
I have a table who looks something like this: USERNAME DATA DATETIME Jhon text1

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.