Pivoting a large row into a single column

Description

None

Environment

None

Observations

I can see that you can specify different renderers for table data. However, when you want to pivot and use the unnest(array) function, can you still select different renderers for different column data?

In the query below, TOTAL_UNITS is integer, NPV, MSRP, COGS are currency and IRR, Margin are text (using %)

Is there a way to show $ or % in the Value column for the respective columns?

Currently, this is how I query

SELECT
unnest(array['Total Units', 'NPV ($)', 'IRR (%)', 'MSRP ($)', 'COGS ($)', 'Channel Margin (US) (%)', 'Gross Margin (%)']) "Field",
unnest(array[(round(cast (total_units as numeric),2)),
(round(cast (npv as numeric),2)),
(round(cast (irr as numeric),2) ),
(round(cast (msrp as numeric),2) ),
(round(cast (cogs as numeric),2)),
(round(cast(channel_margin_us as numeric),2)),
(round(cast (gross_margin as numeric),2) )]) "Value"
FROM product_case
WHERE product_id=1 and exit_id=2

Assignee

Adrien Ragot (Play SQL / Requirement Yogi)

Reporter

motilj

Labels

None

Participants

None

Components

Priority

Configure