日期:2014-05-17 浏览次数:20770 次
SELECT A.*
FROM 主题 A
INNER JOIN ( SELECT TOP 10
pid ,
COUNT(pid) AS num
FROM 用户记录
WHERE 点击 = 1
GROUP BY pid
ORDER BY COUNT(pid) DESC
) B ON A.id = b.pid
ORDER BY B.num
select top 10 b.*
from dbo.用户记录 a
inner join 主题 b on a.pid=b.ID
where a.点击=1
group by a.pid
order by count(a.pid) desc