Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换sql查询_Sql_Ms Access - Fatal编程技术网

转换sql查询

转换sql查询,sql,ms-access,Sql,Ms Access,我已经在sql中使用了此查询,请将此查询转换为用于access数据库 表结构是UserID、Username、LogDate和LogTime WITH [TableWithRowId] as (SELECT ROW_NUMBER() OVER(ORDER BY UserId,LogDate,LogTime) RowId, * FROM @YourTable), [OddRows] as (SELECT * FROM [TableWithRowId] W

我已经在sql中使用了此查询,请将此查询转换为用于access数据库

表结构是UserID、Username、LogDate和LogTime

WITH  
    [TableWithRowId] as 
    (SELECT ROW_NUMBER() OVER(ORDER BY UserId,LogDate,LogTime) RowId, * FROM @YourTable), 
    [OddRows] as  
    (SELECT * FROM [TableWithRowId] WHERE rowid % 2 = 1), 
    [EvenRows] as 
    (SELECT *, RowId-1 As OddRowId FROM [TableWithRowId] WHERE rowid % 2 = 0) 
SELECT  
    [OddRows].UserId, 
    [OddRows].UserName, 
    [OddRows].LogDate, 
    [OddRows].LogTime, 
    [EvenRows].LogDate, 
    [EvenRows].LogTime  
FROM 
    [OddRows] LEFT JOIN [EvenRows] 
    ON [OddRows].RowId = [EvenRows].OddRowId 

好的,Access不支持带有的
。您必须为
TableWithRowId
使用临时表(假设存在与
ROW\u NUMBER()。其他表格,您可以转换为子选项。

@nisha这与它有关吗?是的,先生,它与它有关