I have below as source_data in oracle database,
{{ config(materialized='table') }}
with source_data as (
select
sd.field_value,
af.adco_field_name
from
{{ source('adco', 'sow_src_data') }} sd
join {{ source('adco', 'src_field') }} sf on sd.src_field_id = sf.src_field_id
join {{ source('adco', 'src_mapping') }} sm on sm.src_field_id = sf.src_field_id
join {{ source('adco', 'adco_field') }} af on af.adco_field_id = sm.adco_field_id
where
effective_date = '2024-02-08'
),
I want to pivot the source_data to make adco_field_name rows as columns and corresponding field_value as values for each column.
source_data sample, provided only five rows for simplicity, the actual dataset contains more than 100 rows, making it impractical to hardcode the `ADCO_FIELD_NAME`
ADCO_FIELD_NAME | FIELD_VALUE
--------------- | -----------
SV6M10YP | 15.7
LIBOR180 | 7.95
LIBOR240 | 8.02
Cofi11 | 11.848
Expected output,
SV6M10YP | LIBOR180 | LIBOR240 | Cofi11
---------|----------|----------|---------
15.7 | 7.95 | 8.02 | 11.848
If the above process is tedious to achieve in Oracle, then the Microsoft SQL Server (MSSQL) approach is also acceptable.
I am trying to achieve the pivoted output but unable to produce the expected result.