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.

Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
Jeff
  • 745
  • 6
  • 24

1 Answers1

2
select *
from nodes n 
join nodes nlater
  on n.name = nlater.name 
  and n.reportedat < nlater.reportedat
wickedone
  • 542
  • 1
  • 6
  • 18
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786