The slightly complex SQL (Oracle) encountered in the project is the first five recycling enterprises in each province. select (select pro. p_name from base_province_list pro where pro. p_index = t. p_index | '100') p_name, entp_name, cnt recycling from (select rank () over (partition by p_index order by cnt desc) rk, S. * from (select substr (epc. p_index, 1, 2) p_index, (select em. entp_name from entp_main em where em. entp_id = epc. hs_entp_id) entp_name, count (*) cntfrom entp_pd_callback epcgroup by substr (epc. p_index, 1, 2), epc. hs_entp_id) S) T where T. rk <= 5 SELECT REGEXP_SUBSTR (t. entp_craft, '[^,] +', 1, ul) AS entpcraft, t. * FROM (select * from ENTP_INFO t where t. entp_craft like '%, %' and t. year is not null and is_del = 0) t, (select level ul from dual connect by level <= 100) WHERE 1 = 1 and ul <= LENGTH (t. entp_craft)-LENGTH (REPLACE (t. entp_craft, ',') + 1 order by entp_name asc