Reeya Oberoi
Reeya Oberoi

Reputation: 861

Query to join 2 columns of same table

I have a table txn(id,orig_num,rec_num)

How to write a query to return distinct values present in both column? I want to join these two columns (orig_num and rec_num) and return 1 column (say acct_num) which will have distinct account numbers. I am using sql server

Upvotes: 1

Views: 4008

Answers (1)

juergen d
juergen d

Reputation: 204746

select orig_num as acct_num from your_table
union
select rec_num from your_table

SQLFiddle demo

Upvotes: 4

Related Questions