检索表中的第6至9条记录 [英] Retrieve 6th to 9th record in a table
本文介绍了检索表中的第6至9条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个只有1列的表
名称
A
B
C
D
E
F
G
H
我
J
我想将第6到第9条记录输出为-F G H I
i have a table with only 1 column as
Name
A
B
C
D
E
F
G
H
I
J
i want output as 6th to 9th record as- F G H I
推荐答案
尝试以下方法:
Try this:
SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY column_name) AS RowNum, * FROM Table_name) sub WHERE RowNum between 6 and 9
您必须为此编写程序
You have to write procedure for this
CREATE PROCEDURE ReturnRowsAt
(
@Startpos int,@Endpos int
)
AS
Begin
DECLARE @Table1 AS TABLE (rwid bigint identity(1,1), val nvarchar(255))
INSERT INTO @Table1 (val)
SELECT * FROM yourtablename
SELECT * FROM @Table1 WHERE rwid between @Startpos and @endpos
End
希望这会有所帮助,然后接受并投票回答
--Rahul D.
Hope this helps if yes then accept and vote the answer
--Rahul D.
这篇关于检索表中的第6至9条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文