SELECT a.poid from [Article] a left join [Article] b on a.poid<=b.poid where a.poid<=$cs and b.poid<=$cs group by a.poid having count(b.poid)<=2 之前的語法有錯 修正如下 SELECT top 2 a.poid from [Article] a left join [Article] b on a.poid<=b.poid where a.poid<=$cs and b.poid<=$cs group by a.poid order by count(b.poid) asc