How to Display A for one Condition and B for another condition in single result window of Select statement in SQL Server


To get the result in a single result window, but depending on two different condition you have to display the result. To do so use UNION keyword of sql.

For Example :

select col1,col2, A as Col3 from Table_Name where <condition> UNION select col1,col2, B as Col3 from Table_Name where <condition></pre>

Now you have to change the col1,col2,col3, table name and condition in the above query and execute and see the result.

How useful was this post?

Click on a star to rate it!

Leave a Reply

Your email address will not be published. Required fields are marked *