Skip to Content
0
Former Member
Oct 18, 2012 at 12:17 PM

Transpose Rows in Columns

925 Views

Hey.

I need to transpose a Table.

That's how it looks like:

TABLE:

OBJEK ATINN ATWRT

1 a 5

1 b 8

1 c 6

2 b 4

2 c 9

I want to have following structure:

TABLE2:

OBJEK ATWRTa ATWRTb ATWRTc

1 5 8 6

2 ? 4 9

I thougt of following query:

select "OBJEK",

(case when "ATINN" = 'a' then "ATWRT" end) as "ATWRTa",

(case when "ATINN" = 'b' then "ATWRT" end) as "ATWRTb",

(case when "ATINN" = 'c' then "ATWRT" end) as "ATWRTc"

from

"P1591085134"."AUSP1"

group by "OBJEK"

But the compiler tells me that "ATINN" is not a group by expression...

Without the group by command i get the following result:

OBJEK ATWRTa ATWRTb ATWRTc

1 5 ? ?

1 ? 8 ?

1 ? ? 6

2 ? 4 ?

2 ? ? 9

Is there another possibility? Probably with a stored procedure?