【发布时间】:2012-04-29 03:37:13
【问题描述】:
select name, reported_at from nodes
where reported_at < curdate() or reported_at is null
group by name
输出:
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
通过该声明,我会得到任何报告于/name 的结果表,但该表小于当前日期。
我需要的是只提取具有更多当前信息的重复数据的语句。
例如:
声明只会退出:
ncs-linux-test.edu 2012-03-16
如果有的话
ncs-linux-test.edu
日期早于 2012-03-16。
【问题讨论】:
-
本质上是stackoverflow.com/questions/854128/…,然后您选择每个组中最早的。
-
如果您有两个都为空值的重复项,您期望得到什么?