0

I have a requirement to transpose the column into header.

The Data values is

Column A Column B
-------- --------   
AA       B
AA       C
AD       D

The out put should look like this

AA  AD
--  --
B
C
     D

I tried with pivot but I'm not able to do it without aggregation.

Could someone help me out with this

APC
  • 144,005
  • 19
  • 170
  • 281
Scott77
  • 21
  • 3
  • 1
    Possible duplicate of [Pivot rows to columns without aggregate](http://stackoverflow.com/questions/15674373/pivot-rows-to-columns-without-aggregate) – Aleksej Jan 04 '17 at 08:32

1 Answers1

0

Based on what you've said, maybe you're after something like:

WITH sample_data AS (SELECT 'AA' col_a, 'B' col_b FROM dual UNION ALL
                     SELECT 'AA' col_a, 'C' col_b FROM dual UNION ALL
                     SELECT 'AD' col_a, 'D' col_b FROM dual)
SELECT CASE WHEN col_a = 'AA' THEN col_b END aa,
       CASE WHEN col_a = 'AD' THEN col_b END ad
FROM   sample_data;

AA AD
-- --
B  
C  
   D
Boneist
  • 22,910
  • 1
  • 25
  • 40
  • Thanks guys. Since the values are limited I've also found a way to get the desired output through Oracle Decode – Scott77 Jan 08 '17 at 16:19