[英]Get all rows containing the two highest values of a column
示例表如下所示:
last_update | notes
-------------+--------------------
1449619200 | not that important
1449619200 | rather useless
1449705600 | interesting
1449792000 | very important
1449792000 | very useful
现在,我想要一个SQLite命令,该命令输出带有两个最新更新时间戳(即1449705600和1449792000)的所有行,以便输出表如下所示:
last_update | notes
-------------+--------------------
1449705600 | interesting
1449792000 | very important
1449792000 | very useful
该命令应该是什么样?
select * from yourtable
where last_update in (select distinct last_update
from yourtable
order by last_update desc
limit 2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.