Willian Kane
Willian Kane

Reputation: 11

SQL Query (Display Positive and Negative value with two columns)

I have one column table with negative and positive values and want to display positive and negative values in different columns using SQL Query.

Column
-10000
-17000
 16000
 25000

output should be like

A          B 
-----------------
-10000
            16000
-17000 
            25000

Upvotes: 1

Views: 2748

Answers (1)

Martin Smith
Martin Smith

Reputation: 453287

You can use a couple of CASE expressions.

SELECT CASE
         WHEN [Column] < 0 THEN [Column]
       END AS A,
       CASE
         WHEN [Column] >= 0 THEN [Column]
       END AS B
FROM   YourTable 

Upvotes: 5

Related Questions