如何使用SQL查询检索插入表中的最后5条记录? [英] How to retrieve last 5 records which was inserted in the table using SQL query?
本文介绍了如何使用SQL查询检索插入表中的最后5条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
2014年8月4日下午1:00:00英语P
8/4/2014 10:00:00 AM数学A
8/7/2014上午10:00:00数学P
8/8/2014 10:00:00 AM数学P
8/5/2014 10:00:00 AM Maths P
这是我的桌子。假设我想找出最近插入的5条记录。我也希望在时间的基础上找到它。然后如何编写SQL查询来检索数据?
解决方案
尝试:
SELECT TOP 5 * FROM MyTable ORDER BY DateColumn DESC 跨度>
8/4/2014 1:00:00 PM English P
8/4/2014 10:00:00 AM Maths A
8/7/2014 10:00:00 AM Maths P
8/8/2014 10:00:00 AM Maths P
8/5/2014 10:00:00 AM Maths P
This is my table. Suppose I want to find out 5 records which was inserted recently. I also want to find it out on the basis of time. Then how to write a SQL query to retrieve data?
解决方案
Try:
SELECT TOP 5 * FROM MyTable ORDER BY DateColumn DESC
这篇关于如何使用SQL查询检索插入表中的最后5条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文