Monday, March 12, 2012

Getting output of a one row into 4 columns

I am trying to find a way how to query following data from a table that looks like this:

ColA ColB ColC

1 2 3

Output should look like this:

ColA

1

2

3

You could use a UNION ALL to combine the results of 3 separate SELECTstatements. If you want to eliminate duplicate values, use aplain UNION instead:
SELECT
   ColA AS ColA
FROM
   myTable
UNION ALL
SELECT
   ColB AS ColA
FROM
   myTable
UNION ALL
SELECT
   ColC AS ColA
FROM
   myTable

|||thanx

No comments:

Post a Comment