1
select name, reported_at from nodes where reported_at < curdate() or reported_at is null group by name 

Output:

name reported at ncs-linux-test.edu 2012-03-16 18:36:03 ocdev1.net 2012-04-06 16:32:02 pinc-ctm.net NULL 

With that statement, I get any results form reported at/name that are less than the current date.

What I need though is the statement to only pull out data that has a duplicate(s) with more current information.

For example:

The statement would only pull out:

ncs-linux-test.edu 2012-03-16 

if there was an

ncs-linux-test.edu 

with a date more current than 2012-03-16.

2
  • 1
    That's essentially stackoverflow.com/questions/854128/…, and then you pick the earliest per group. Commented Apr 17, 2012 at 18:57
  • What are you expecting to get if you have duplicates both with null values? Commented Apr 17, 2012 at 19:06

1 Answer 1

2
select * from nodes n join nodes nlater on n.name = nlater.name and n.reportedat < nlater.reportedat 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.