用top关键词能实现查询前几条的记录吗?
比如查询前5条纪录
select top 5 from table;
这样行不行?应该怎么写?
问题点数:20、回复次数:10Top
1 楼study_sql(学习SQL)回复于 2004-12-02 08:53:44 得分 0
希望大家能帮帮我,我想学习一下top的用法Top
2 楼drk928(一起看斜阳)回复于 2004-12-02 08:58:56 得分 3
SQLSERVER 的帮助自己文档,自己看吧.Top
3 楼zhuxiaojun2002(车房志之扯坏的领带)回复于 2004-12-02 09:11:16 得分 3
select top 5 * from tableTop
4 楼zhuxiaojun2002(车房志之扯坏的领带)回复于 2004-12-02 09:12:43 得分 3
SELECT TOP 5 ID, Name
FROM table
ORDER BY idTop
5 楼qzb0818(漂来漂去)回复于 2004-12-02 09:17:29 得分 3
select top 5 * from table where condition
Top
6 楼Truly()回复于 2004-12-02 09:20:59 得分 3
select top 5 * from table
SQLSERVER联机丛书
有详细语法Top
7 楼chen99yjeyotech(语过添情)回复于 2004-12-02 09:22:06 得分 3
上面都说了.
比如查询前10条记录
select top 10 * from table where 条件Top
8 楼ianok(再菜我也要up出個星來)回复于 2004-12-02 09:25:04 得分 2
The TOP clause limits the number of rows returned in the result set.
TOP n [PERCENT]
n specifies how many rows are returned. If PERCENT is not specified, n is the number of rows to return. If PERCENT is specified, n is the percentage of the result set rows to return:
TOP 120 /*Return the top 120 rows of the result set. */
TOP 15 PERCENT /* Return the top 15% of the result set. */.
If a SELECT statement that includes TOP also has an ORDER BY clause, the rows to be returned are selected from the ordered result set. The entire result set is built in the specified order and the top n rows in the ordered result set are returned.
Top
9 楼caiyi000(BAICAI)回复于 2004-12-02 09:27:16 得分 0
可以的。Top
10 楼study_sql(学习SQL)回复于 2004-12-02 09:29:03 得分 0
多谢楼上兄弟们了Top




