Slightly complicated SQL (Oracle) encountered in the project)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.