views:

58

answers:

1

I have used this query in sql,pls convert this query to use for access database.

Table structure is 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 
+1  A: 

AFAIK, Access doesn't support WITH. You'll have to use a temp table for TableWithRowId (assuming some equivalent of ROW_NUMBER() exists, which may not). The other tables, you can just convert to sub-selects.

Marcelo Cantos