In SQL Server2005, Row_number() function is used to retrieve the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition. Which is very useful when implementing paging through a large number records in Table. Is there any function available in SQLite similar to this.

没有正确的解决方案

其他提示

No. Usually you'd handle these sorts of details with your own code.

You may simulate the Raw Numbering done in a ROW_NUMBER() function with code similar to the below format.

CREATE TABLE Temp.Output AS
SELECT *
FROM  (
    SELECT 10 AS ID,'Darren' AS Name
    UNION ALL
    SELECT 20,'Roger'
    UNION ALL
    SELECT 30,'Emil'
    UNION ALL
    SELECT 40,'Doug'
    UNION ALL
    SELECT 50,'Martin'
)
ORDER BY Name ASC
;
SELECT ROWID AS ROWNUMBER, ID, Name
FROM Temp.Output
;
DROP TABLE Temp.Output
;

It will not support "PARTITION BY" for grouping the results (but with some additional SQL you may be able to).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top