Row and column conversion _wmsys.wm_concat

Source: Internet
Author: User

Requirements Description

Loc_sys_busi_strategy is a longitudinal table that needs to be converted into a horizontal table to facilitate Redis queue processing.
Source data format

650) this.width=650; "src=" http://img.blog.csdn.net/20160607220002619 "alt=" here write a picture describing "title=" "style=" border:none; "/ >


Requirements format

650) this.width=650; "src=" http://img.blog.csdn.net/20160607220048306 "alt=" here write a picture describing "title=" "style=" border:none; "/ >


Note that the Speed,area is the title heading in the demand format.

Format conversion

Select Busirule_id,element_key,element_val from Loc_sys_busi_strategy;

650) this.width=650; "src=" http://img.blog.csdn.net/20160607220424354 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Title Heading Conversion
Select busirule_id, ' Speed ' speed, ' area ' area from loc_sys_busi_strategy where 1 = 2 Unionselect busirule_id, Decode (Element_key, Upper (' Speed '), Element_val), Decode (Element_key, Upper ("area"), Element_val) from Loc_sys _busi_strategy;

650) this.width=650; "src=" http://img.blog.csdn.net/20160607220517142 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Merge
Select busirule_id, To_char (wmsys.wm_concat) speed, To_char (area) area from (select B usirule_id, ' Speed ', "area" area from loc_sys_busi_strategy where 1 = 2 Unionselect busirule_id, Dec Ode (Element_key, Upper (' Speed '), Element_val), Decode (Element_key, Upper ("area"), Element_val) from Loc_sys_ Busi_strategy) Group by busirule_id;

650) this.width=650; "src=" http://img.blog.csdn.net/20160607220611433 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

This article is from the "90SirDB" blog, be sure to keep this source http://90sirdb.blog.51cto.com/8713279/1787893

Row and column conversion _wmsys.wm_concat

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.