SQL 查询的正确语法 (SQL 2008)



>我在SQL Server 2008中有3个表:

ACCOUNT(username,password,task);
COMMENT(idcom,content,username,time,idtopic);
TOPIC(idtopic,title);

我有一个查询来获取 NUM(行号)、idcom、内容、iptopic、用户名、任务、时间:

select ROW_NUMBER() over (order by (select 1)) as NUM, idcom, content, idtopic, b.username, b.task, time 
 from COMMENT a 
 LEFT JOIN ( select username, task from ACCOUNT) b 
 ON a.username=b.username 
 where idtopic='1' ---> I call it: Temp Table

然后我想从第 6 行 (7,8,9,...) 获取临时表中的所有行。我已经尝试了很多次,但似乎我不知道正确的语法?帮助?

从 (选择 ROW_NUMBER() 中选择 * 作为 NUM, idcom, content, idtopic, b.username, b.task, time 从评论 a 左加入(从帐户中选择用户名,任务)b 在 a.用户名=b.用户名 其中 idtopic='1' )x 其中 x.Num> 6

最新更新