1

I am running the following SQL query:

select distinct col + "abc" value1, col+ "xyz" value2
from table_name
where col = "1234567890"

This returns output as:

value1        value2
1234567890abc 1234567890xyz

But I want the output as:

value
1234567890abc
1234567890xyz

How can I do this?

2 Answers 2

1

use union all

select distinct col + "abc" value
from table_name
where col = "1234567890"
union all
select distinct col+ "xyz" 
from table_name
where col = "1234567890"
Sign up to request clarification or add additional context in comments.

2 Comments

You accepted the answer, but why someone downvoted me? that's a question :)
Not sure who downvoted, but I just upvoted your answer. Thanks :)
0

use concat and union all

select concat(col, 'abc') value1
from table_name
where col = '1234567890'
union all
select concat(col, 'xyz')
from table_name
where col = '1234567890'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.