Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Row to column or Pivot

Ace Rah5 days ago — edited 4 days ago

Hi All

I have to create multiple rows to single column but shows multiple rows. Please guide.

Input:

Cust_id Account_id Amt Inv_code Center
111 185326 85000 A180 7000
111 228965 25000 A160 7000
111 896423 90000 B580 7000
111 228965 500000 A160 7000
975 855685 55000 R444 9000
975 585456 75000 T150 9000

Buketing is based on total sum of Amt: ≤1M then '<1M', >1M and <5M then '>1M & <5M' , ≥5M Then ' ≥5M'

Output:

Cust_id Account_id1 Amt_1 Inv_code_1 Center Account_id2 Amt2 Inv_code2 Account_id3 Amt3 Inv_code3 Bucket Count
111 185326 85000 A180 7000 228965 525000 A160 896423 90000 B580 >1M 4
975 855685 55000 R444 9000 585456 75000 T150 9000 null null <1M 2

Thanks

Ace

Comments

Post Details

Added 5 days ago
6 comments
128 views