oracle 分组后取每组中固定行数

终于到数据库了...... partition by 暂时 先记录下...  以后在详解....

select * from (  

      select tpi.*,  

            row_number() over (partition by tpi.org_city order by tpi.org_city) rn  

                from t_product_index tpi  

                        where tpi.org_city in (

                        select org_city from(

select count(1) ss,org_city from t_product_index where type = 0 group by org_city order by ss desc

) where rownum <10

                        ) and tpi.type = 0

) where rn <= 8 


版权声明:本文为aa764336646原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。