Skip to content

Tag: unpivot

Transpose using column names in Oracle SQL

I have worked a bit in pivot/unpivot in Oracle SQL but this one seems little complex and need some help here. the below is my table design year Comp_A_prev_yr_due_ct Comp_A_prev_yr_due_amt Comp_A_curr_yr_due_ct Comp_A_Curr_yr_due_amt 2019 100 1000 101 1001 like this I have multiple companies as columns (each …

UNPIVOT Holiday Hours

I have a table, that keeps track of store holiday hours: This is a highly oversimplified table. There’s about 30 columns horzontially consisting of store operating hours by date – It continues (DATE3, TIMES3, DATE4, TIMES4, etc). I need to unpivot the values vertically, ensuring the date and time …

logic to create more rows in sql

I have a table1 that I wanted to transform into the expected table. Expected table logic for columns: cal: comes from cal of table1. ID comes from the ID of table1. code: this is populated with lp or fp depending upon if we have a value in f_a then we create a new record with fp as code. corresponding to