sql中排名前十的记录 [英] Top 10 records in sql

查看:394
本文介绍了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


这篇关于sql中排名前十的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆