문제

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