79651709

Date: 2025-06-03 18:09:53
Score: 1
Natty:
Report link

i find CASE / WHEN to be easier to construct, as in @john-rotenstein's answer, but Redshift does have a built-in PIVOT function:

SELECT
  a,
  b,
  id
FROM
  (SELECT * FROM temp)
  PIVOT
  (MAX(value) FOR source IN ('A', 'B'))
ORDER BY
  id
;
+----+----+---+
|a   |b   |id |
+----+----+---+
|C123|V123|111|
|C456|V456|222|
+----+----+---+
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @john-rotenstein's
  • Low reputation (0.5):
Posted by: jydiw