只有5个冠军; 那是我的桌子:
ID Title Time
1 DA-UB 2017-05-14 15:02:03
2 UB-SA 2017-05-14 15:03:03
3 ER-UB 2017-05-14 15:04:03
4 DA-UB 2017-05-14 15:05:03
5 UB-sa 2017-05-14 15:06:03
6 ER-UB 2017-05-14 15:07:03
7 OR-SA 2017-05-14 15:10:03
8 ER-DA 2017-05-14 15:11:03
我想看到这个(最后添加5行)
4 DA-UB 2017-05-14 15:05:03
5 UB-sa 2017-05-14 15:06:03
6 ER-UB 2017-05-14 15:07:03
7 OR-SA 2017-05-14 15:10:03
8 ER-DA 2017-05-14 15:11:03
答案 0 :(得分:1)
SELECT TOP 5
*
FROM
[YourTable]
ORDER BY
Time DESC
答案 1 :(得分:1)
使用LIMIT
:
select *
from your_table
order by time desc
limit 5
根据以下评论中的最新更新,您可以使用有限的相关查询来获取每个标题的最新行,然后将结果限制为5行。
select *
from your_table t1
where id = (
select id
from your_table t2
where t1.title = t2.title
order by time desc
limit 1
)
order by time desc
limit 5;