Paramertize仅在DB2中获取第n个行 [英] Paramertize Fetch First n Rows Only in DB2
本文介绍了Paramertize仅在DB2中获取第n个行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试执行以下操作:
I'm trying to do the following:
select *
from table
fetch first @param rows only
@param是一个int。
@param is an int.
DB2不会有。我听说过与 ||
连接在一起,但我似乎无法让它工作。
DB2 would not have it. I've heard of concatenating it with ||
, but I can't seem to get that to work.
任何人都有这方面的经验?
Anyone have experience with this?
(PS我看到一个类似的问题),但并不明白他使用':1'的方法。
(PS I saw a similar question) but didn't understand his approach using ':1'.
推荐答案
您可以尝试以下操作:
select t.*
from (select r.*, row_number() over() as row_num
from table r) as t
where row_num <= @param
这篇关于Paramertize仅在DB2中获取第n个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文