34,588
社区成员
发帖
与我相关
我的任务
分享
select * from (
select [Id],[Mid],[Recommend],[Tops],[Click],[CreateTime],ids=ROW_NUMBER()
over(partition by Recommend,Tops order by CreateTime desc) from Product
where Mid in (5,6,7,13,14,16,17,18) and ([Recommend]>0 or Tops>0) and [Status]>0
)a where (ids<=2 and Mid in (5,6,7,14,16,17,18)) or (ids<=2 and Mid=13) or (ids<=1 and Tops>0)
order by CreateTime,ids desc