[SOLVED] Get list from two columns

Issue

I want to create a SQL query which gives a list in an order based on the below sequence

X|Y|
----
D|C|
B|A|
C|B|

I want one list in sequence

Z
    
A
B
C
D

No Idea, from where to start

Solution

create table #data(X nvarchar(40), Y nvarchar(40) )

INSERT INTO #data
SELECT 'D', 'C' union
SELECT 'B', 'A' union
SELECT 'C', 'B'


SELECT X FROM #data
UNION
SELECT Y FROM #data
ORDER BY 1

enter image description here

Answered By – Gaurang Prajapati

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.