在T-SQL中访问查询生成结果,如ROW_NUMBER()

我们在MS Access中有ROW_NUMBER函数吗? 如果有,请让我知道任何语法,因为我卡在这里。 我试过论坛,但我得到的SQL Server语法。 以下是我的查询:

select ROW_NUMBER() OVER (ORDER BY t.TID) AS uni , t.TSource as [Source], t.TText as [Text], u.Name as [UserId], u.Image_Url as [ImageFilePath], from table1 t inner join table2 u on t.UserId = u.UIds 

但它给语法错误。

在Access SQL中,我们有时可以使用联接来产生sorting。 例如,对于[table1]

 TID UserId TSource TText --- ------ ------- ----- 412 homer foo bar 503 marge baz thing 777 lisa more stuff 

查询

 SELECT t1a.TID, t1a.UserId, t1a.TSource, t1a.TText, COUNT(*) AS TRank FROM table1 AS t1a INNER JOIN table1 AS t1b ON t1a.TID >= t1b.TID GROUP BY t1a.TID, t1a.UserId, t1a.TSource, t1a.TText 

产生

 TID UserId TSource TText TRank --- ------ ------- ----- ----- 412 homer foo bar 1 503 marge baz thing 2 777 lisa more stuff 3 

我们可以用它作为我们JOIN到另一个表中的子查询

 select t.TRank as uni, t.TSource as [Source], t.TText as [Text], u.Name as [UserId], u.Image_Url as [ImageFilePath] from ( SELECT t1a.TID, t1a.UserId, t1a.TSource, t1a.TText, COUNT(*) AS TRank FROM table1 AS t1a INNER JOIN table1 AS t1b ON t1a.TID >= t1b.TID GROUP BY t1a.TID, t1a.UserId, t1a.TSource, t1a.TText ) AS t INNER JOIN table2 AS u ON t.UserId = u.UIds 

产生类似的东西

 uni Source Text UserId ImageFilePath --- ------ ----- ------------ ------------- 1 foo bar HomerSimpson whatever1 2 baz thing MargeSimpson whatever2 3 more stuff LisaSimpson whatever3