语句如下 一. 
SELECT top          2 user_Integral_tbl.user_Integral_customers_id,sum( user_Integral_tbl.user_Integral_Numerical) as 总成绩  FROM user_Integral_tbl 
where   not exists  (SELECT top 2 user_Integral_tbl.user_Integral_customers_id  FROM user_Integral_tbl GROUP BY user_Integral_tbl.user_Integral_customers_id ORDER BY  sum( user_Integral_tbl.user_Integral_Numerical)  DESC)
GROUP BY user_Integral_tbl.user_Integral_customers_idORDER BY 总成绩 DESC二.
SELECT top          2 user_Integral_tbl.user_Integral_customers_id,sum( user_Integral_tbl.user_Integral_Numerical) as 总成绩  FROM user_Integral_tbl  where  user_Integral_tbl.user_Integral_customers_id not in (SELECT top 2 user_Integral_tbl.user_Integral_customers_id  FROM user_Integral_tbl GROUP BY user_Integral_tbl.user_Integral_customers_id ORDER BY  sum( user_Integral_tbl.user_Integral_Numerical)  DESC)GROUP BY user_Integral_tbl.user_Integral_customers_idORDER BY 总成绩 DESC

解决方案 »

  1.   

    因为一里面的not exists(子查询),子查询总是有结果返回,如果子查询没有结果返回,同样的查询也没有结果返回
      

  2.   

    修改一. 
    SELECT top          2 user_Integral_tbl.user_Integral_customers_id,sum( user_Integral_tbl.user_Integral_Numerical) as 总成绩  FROM user_Integral_tbl 
    GROUP BY user_Integral_tbl.user_Integral_customers_idORDER BY 总成绩 DESC