每个分类取5条, Sql解决方法

一。select * from(
select ID,ShopClient_ID,Name,Icon,HitCount,Class1_ID,row_number() over(partition by Class1_ID order by HitCount desc)
as rowindex from tab_Goods)a
where rowindex<=5

二。SELECT  * FROM tab_Goods a
WHERE (SELECT count(*) FROM tab_Goods b WHERE b.Class1_ID=a.Class1_ID AND b.ID>a.ID)<5
ORDER BY Class1_ID desc

每个分类取5条, Sql解决方法,布布扣,bubuko.com

每个分类取5条, Sql解决方法

上一篇:Oracle动态性能表-V$SESSION_WAIT,V$SESSION_EVENT


下一篇:ORACLE_ERP帐务分录