sql中排名前十的记录
问题描述:
大家好.
我在数据库中有50条记录.我必须在运行时显示前10条记录.
现在,当我添加新记录时,它就没有了. 51.
我希望它低于10,这样我就可以显示数据库中的前10条记录.或者,如果还有其他显示方式,请告诉我.
Hello to all.
I have 50 records in database. I have to display top 10 records at run-time.
Now when i add new record it comes at no. 51.
I want that it comes under 10, so that i can display top 10 records from data base. Or if there is any other way to display it then please tell me.
答
在查询中使用订单方式
用这个.
use order by in your query
use this.
Select top 10 ProductId , ProductName from Products order by productId desc
希望对您有帮助
Hope this helps
您也可以按添加日期订购
如:
从按日期排序的产品订单中选择前10个ProductId,ProductName添加了desc
you can also order by date added
as:
Select top 10 ProductId , ProductName from Products order by dateAdded desc