将SQLServer查询转换为SQLite

时间:2017-03-16 13:13:31

标签: sql-server sqlite

下面是我想要将其转换为SQLite的SQL Server查询 是否有任何在线收费可用于将SQL查询转换为SQLite

select variable_col,
    timecomes_col,
    lead(timegoes_col, 1, 0) over (
        order by variable_col
        ) as timegoes
from Table1

1 个答案:

答案 0 :(得分:0)

我尝试在您的查询的MSSQL中转换MSSQL LEAD:

SELECT VARIABLE_COL
    ,TIMECOMES_COL
    ,LEAD(TIMEGOES_COL, 1, 0) OVER (ORDER BY VARIABLE_COL) AS TIMEGOES
FROM TABLE1
;

不使用ANALITYCS FUNCTIONS:

    SELECT VARIABLE_COL
        ,TIMECOMES_COL
        ,LEAD(TIMEGOES_COL, 1, 0) OVER (ORDER BY VARIABLE_COL) AS TIMEGOES /* this is here to compare values*/
        , (SELECT TOP 1 TIMEGOES_COL FROM TABLE1 T2 WHERE TABLE1.TIMEGOES_COL < T2.TIMEGOES_COL ORDER BY T2.VARIABLE_COL) AS TIMEGOES_SUCC
FROM TABLE1
    ;

在sqlite中应该是:

SELECT VARIABLE_COL
            ,TIMECOMES_COL              
            , (SELECT  TIMEGOES_COL FROM TABLE1 T2 WHERE TABLE1.TIMEGOES_COL < T2.TIMEGOES_COL ORDER BY T2.VARIABLE_COL LIMIT 1) AS TIMEGOES_SUCC
    FROM TABLE1
        ;

正如Panagiotis正确建议的那样,这可能会导致性能下降(特别是对于大中型数据表)