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!

Row to column or Pivot

Ace RahMar 24 2025 — edited Mar 25 2025

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

This post has been answered by Solomon Yakobson on Mar 31 2025
Jump to Answer
Comments
Post Details
Added on Mar 24 2025
8 comments
366 views