0

Just wondering if this is possible in Sybase SQL Anywhere. Ive found references to PIVOT which makes a row into a column but not the other way around.

My Table is made up of:

SEQUENCE (PKEY), LINE01, Line02, Line03, ...... Line16
1              , A     , B     , C     ,        D
2              , A     , B     , C     ,        D

I want to run a SELECT on this table which returns:

SEQUENCE, LINE
1       , A
1       , B
1       , C
1       , D
2       , A
2       , B
2       , C
2       , D

Is this possible?

CathalMF
  • 9,705
  • 6
  • 70
  • 106
  • This would be an UNPIVOT which converts your columns into rows. I don't believe Sybase has an unpivot function so you'd have to look at using `UNION ALL` to select from each column. – Taryn Jul 17 '14 at 15:17
  • OK Cool. A UNION ALL seems to have done the trick thanks. Any idea what 16 UNION ALL's on the same table would be like on a table with 50000 records? – CathalMF Jul 17 '14 at 15:28
  • Put it as an answer and ill mark it. – CathalMF Jul 17 '14 at 15:29
  • You'd have to try it. I'd answer but it's a duplicate :) – Taryn Jul 17 '14 at 15:29
  • I am not sure I understand the difference between making columns into rows, and making rows into columns ... are they not both ninety degree rotations? – Hugh Jones Jul 17 '14 at 15:54

0 Answers0