社区
MS-SQL Server
帖子详情
select: 从表a中选择前n个记录,按降序排列,怎么select?
yueyue
2001-10-15 11:18:22
...全文
340
19
打赏
收藏
select: 从表a中选择前n个记录,按降序排列,怎么select?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
19 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
smartdonkey
2001-10-15
打赏
举报
回复
错了
改正:
select col1,col2 from(select top n col1,col2 from mytable) newtable order by col1 desc
如何
smartdonkey
2001-10-15
打赏
举报
回复
select col1,col2 from(select top n col1,col2 from mytable) order by col1
如何
KingSunSha
2001-10-15
打赏
举报
回复
什么数据库? 版本号?
不同的数据库处理方法不一样的.
blueflame
2001-10-15
打赏
举报
回复
比如:
select top 10 * from filebook where bid<>9999 and reid=0 order by fhits desc
yueyue
2001-10-15
打赏
举报
回复
楼上的两位试过了吗?
select a.au_id from ( select top 8 au_id from authors ) as a order by au_id desc
也不对。
我说的是选出前N条,这N条按降序排列
balloy
2001-10-15
打赏
举报
回复
select top n * from a order by b desc
a_fee
2001-10-15
打赏
举报
回复
支持sql-3的数据库,都可用select top N column_name from a order by b dsec
yueyue
2001-10-15
打赏
举报
回复
按字段b降序排列
yueyue
2001-10-15
打赏
举报
回复
呵,对了。
不知有没有更简单的语句
oyo111111
2001-10-15
打赏
举报
回复
好吧,这个总该可以了吧
select a.au_id from (select b.au_id from authors b order by b.au_id) a order by a.au_id desc
oyo111111
2001-10-15
打赏
举报
回复
排序和不排序结果是不一样的,不可相提并论。
yueyue
2001-10-15
打赏
举报
回复
可是
select au_id from authors order by au_id desc
结果是按au_id的顺序排序的呀
oyo111111
2001-10-15
打赏
举报
回复
要明确一点下面二句的au_id结果是不一样的
select * from authors
select au_id from ahthors
所以
select top 8 * from authors
select top 8 au_id from ahthors
得出au_id结果也是不一样的
你要哪个
yueyue
2001-10-15
打赏
举报
回复
楼上的对是对了。
但是*不是太浪费了吗?我只要au_id
oyo111111
2001-10-15
打赏
举报
回复
select * from (select top 8 * from authors) tmp_table order by au_id desc
试试, 没问题可以加分了。
yueyue
2001-10-15
打赏
举报
回复
这是全部:
172-32-1176
213-46-8915
238-95-7766
267-41-2394
274-80-9391
341-22-1782
409-56-7008
427-17-2319
472-27-2349
486-29-1786
527-72-3246
648-92-1872
672-71-3249
712-45-1867
722-51-5454
724-08-9931
724-80-9391
756-30-7391
807-91-6654
846-92-7186
893-72-1158
899-46-2035
998-72-3567
这是选择后的:
722-51-5454
712-45-1867
648-92-1872
527-72-3246
427-17-2319
409-56-7008
238-95-7766
213-46-8915
语句:
select au_id from (select top 8 au_id from authors) newtable order by au_id desc
KingSunSha
2001-10-15
打赏
举报
回复
同意smartdonkey(聪明的毛驴)!
yueyue
2001-10-15
打赏
举报
回复
我用的是sql server2000中自带的数据库pubs.
从表authors中查询au_id前8个,按降序排列
yueyue
2001-10-15
打赏
举报
回复
ms sql server 2000
c语言找出最大值和最小值并按降序排输出,C语言用排序法给十个数
降序排列
,用C语言编写,输入10个数按
降序排列
...
问题标题C语言用排序法给十个数
降序排列
,用C语言编写,输入10个数按
降序排列
2019-6-4来自ip:14.161.145.86的网友咨询浏览量:562手机版问题补充:C语言用排序法给十个数
降序排列
,用C语言编写,输入10个数按
降序排列
网友答案#includeint main(){int a10,temp;int i,j,k;for(i=0;iscanf("%d",&ai);for(i=...
plsql 排序_在PLSQL
中
怎么能取到表
中
按ID
降序排列
的
前
十条
记录
???
在PLSQL
中
怎么能娶到表
中
按ID
降序排列
的
前
十条
记录
的sql语句是:
select
rownum,t.*from(
select
*fromtestorderbyiddesc)twhererownum<11;PLSQL是连接的oracle数据库,oracle
中
没有limit(limit是mysql
中
的用法)、top(top是sqlserver)关键字,oracle
中
限制行数条件是用rownum。P...
oracle 查询
降序排列
,Oracle 子查询,按
降序排列
,取
前
n条
比如,有一个student 表:id student_name1 s12 s203 s304s405...
mysql降序排序后取第一条
记录
_怎么从mysql按某一字段
降序排列
后取出有并列数据的
记录
?...
你的位置:问答吧-> PHP-> 问题详情怎么从mysql按某一字段
降序排列
后取出有并列数据的
记录
?想要求出学号为202开头的学生总分
前
N名的语文平均分。但是以下php语句查询后,$num取总分
前
7名的时候,显示出来的学号明显不对。请问:这个错在哪里?怎么改正?学号 语文 数学 总分20313 108 141 ...
各个数据库
中
,查询
前
n条
记录
的方法
一、各个数据库
中
,查询
前
n条
记录
的方法 1、SQL查询
前
10条的方法为: 1.
select
top X * from table_name 查询
前
X条
记录
,可以改成需要的数字,比如
前
10条。 2.
select
top X * from table_name order by colum_name desc 按colum_name属性降序排序查询
前
X条
记录
,“order by” 后紧跟要排序的属性列名,其
中
desc表示降序,asc表示升序(默认也是升序方式)。 3.
select
top n * from (s
MS-SQL Server
34,590
社区成员
254,589
社区内容
发帖
与我相关
我的任务
MS-SQL Server
MS-SQL Server相关内容讨论专区
复制链接
扫一扫
分享
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章