Row_number() function for Informix

橙三吉。 提交于 2019-12-13 16:37:42

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/7420458/row-number-function-for-informix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!