且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Informix的Row_number()函数

更新时间:2023-02-06 11:31:17

p>如果,如果出现,你正在寻求获得第一行1-100,然后行101-200,依此类推,那么你可以使用更直接(但非标准)语法。



获取101-200行:

  SELECT SKIP 100 FIRST 100 t。* 
FROM表AS T
WHERE ...其他条件...

您可以使用宿主变量代替字面值100(或在不同的迭代中为占位符使用不同值的单个预准备语句)。


Does informix has a function similar to the SQLServer and Oracle's row_number()? I have to make a query using row_number() between two values, but I don't know how.

This is my query in SQLServer:

SELECT col1, col2 
FROM (SELECT col1, col2, ROW_NUMBER() 
OVER (ORDER BY col1) AS ROWNUM FROM table) AS TB 
WHERE TB.ROWNUM BETWEEN value1 AND value2

Some help?

If, as it appears, you are seeking to get first rows 1-100, then rows 101-200, and so on, then you can use a more direct (but non-standard) syntax. Other DBMS have analogous notations, handled somewhat differently.

To fetch rows 101-200:

SELECT SKIP 100 FIRST 100 t.*
  FROM Table AS T
 WHERE ...other criteria...

You can use a host variable in place of either literal 100 (or a single prepared statement with different values for the placeholders on different iterations).