SELECT TOP 20 * FROM QuestionTable as a WHERE  (a.CurrentState='发布' or a.CurrentState='关注') and QuestionTypeCode in('DiannaoChangshi')  and  a.QuestionID >(SELECT ISNULL(MAX(a.QuestionID),0) FROM (SELECT TOP (20*1-20) a.QuestionID FROM QuestionTable as a WHERE (a.CurrentState='发布' or a.CurrentState='关注') and QuestionTypeCode in('DiannaoChangshi')  and  1=1 ORDER BY  a.QuestionID) A ) ORDER BY  a.QuestionIDsql2005的语句 麻烦各位了!

解决方案 »

  1.   

    在2000里top后不支持表达式或变量,只能是一个值 
      

  2.   

    SELECT TOP 20 * 
    FROM QuestionTable as a 
    WHERE (a.CurrentState='发布' or a.CurrentState='关注') and QuestionTypeCode in('DiannaoChangshi') 
    and a.QuestionID >(SELECT ISNULL(MAX(a.QuestionID),0) 
                       FROM (SELECT TOP (20*1-20) a.QuestionID 
                             FROM QuestionTable as a 
                             WHERE (a.CurrentState='发布' or a.CurrentState='关注') 
                                 and QuestionTypeCode in('DiannaoChangshi') 
                                 and 1=1 ORDER BY a.QuestionID) A 
                      ) 
    ORDER BY a.QuestionID
      

  3.   

    SELECT TOP 20 * FROM QuestionTable as a WHERE 
    (a.CurrentState='发布' or a.CurrentState='关注') 
    and QuestionTypeCode in('DiannaoChangshi') 
    and a.QuestionID >(
    SELECT ISNULL(MAX(a.QuestionID),0) FROM 
      (SELECT TOP (20*1-20) a.QuestionID FROM QuestionTable as a WHERE 
      (a.CurrentState='发布' or a.CurrentState='关注') 
      and QuestionTypeCode in('DiannaoChangshi')
       and 1=1 ORDER BY a.QuestionID
       ) A 
       ) ORDER BY a.QuestionID
    语法没问题