select
top 7
t1.pid as pid
,sum(cast(t1.buy_num as int)) as buy_num
,t2.name as name
,t2.price as price
,t2.small_pic_url as small_pic_url
from t_order_details t1,tb_shang_pin t2
where t1.pid=t2.id and t2.flag=1 and t2.status=4
group by t1.pid,t2.name,t2.price,t2.small_pic_url
order by buy_num desc