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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:25:03+00:00 2026-06-10T18:25:03+00:00

Given a very simplified table with the columns Name, Action, Status, Timepoint 1 A

  • 0

Given a very simplified table with the columns

  Name, Action, Status,   Timepoint
1 "A"   "Open"  "OK"      "2012-09-04 10:10:00"
2 "A"   "Close" "OK"      "2012-09-04 10:05:00"
3 "A"   "Close" "ERROR"   "2012-09-04 10:02:00"
4 "B"   "Look"  "NICE"    "2012-09-04 10:05:00"
5 "B"   "Blow"  "COLD"    "2012-09-04 10:00:00"
6 "C"   "Laugh" "OK"      "2012-09-04 10:02:00"
7 "C"   "Laugh" "MUTE"    "2012-09-04 10:00:00"

How do I most efficiently select each row for a combination of Name and Action but only of the Action of the newest Timepoint?
In the above example it would return rows

1, 2, 4, 5, 6

The working implementation fetches the rows and uses a sub query to only return if there are 0 rows with the same Name, Action combination of a newer Timepoint. But that seems very inefficient when the data set becomes large. It’s something like this

SELECT Name, Action, Status, Timepoint
FROM foobar
WHERE Name IN (... Names of interest ...) AND 
Status IN (... statuses of interest ...) AND
(SELECT COUNT(*) FROM foobar AS t2 WHERE t2.Name = Name AND t2.Status = Status AND t2.Timepoint > Timepoint) = 0
order by Name, Timepoint
  • 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-10T18:25:05+00:00Added an answer on June 10, 2026 at 6:25 pm
    Select *
    from 
    (
          select *,
                 row_number() over (partition by Name, Action order by timepoint desc) RN
          from yourtable
    ) v
    where RN = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a (simplified) table CREATE TABLE `transactions` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `CREATION_DT`
The title doesn't describe this very well, but assuming the following simplified table in
Very simplified, a table with some sample data: action_date account_id 1/1/2010 123 1/1/2010 123
Given a very large string. I would like to process parts of the string
Given this very familiar model of prototypal construction: function Rectangle(w,h) { this.width = w;
First off, I've been given a very tight deadline (read: measured in minutes) to
This code works great for generating thumbnails, but when given a very large (100MB+)
I'm trying to do some very basic time math - basically, given inputs of
this is probably a very stupid question; in a bash script, given the output
I have a table schema similar to the following (simplified): CREATE TABLE Transactions (

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.