Need to get the result as positive and negative numbers from one column to different columns from one table
3 answers
select A.Col1 as POSITIVE,
B.Col1 as NEGATIVE
FROM A
FULL JOIN A as B on (-A.col1=B.Col1)
WHERE A.Col1>0 or B.Col1 < 0
ORDER BY ISNULL(A.Col1,-B.Col1)
If POSITIVE values always exist for every NEGATIVE in the table, use LEFT JOIN instead of FULL:
select A.Col1 as POSITIVE,
B.Col1 as NEGATIVE
FROM A
LEFT JOIN A as B on (-A.col1=B.Col1)
WHERE A.Col1>0
ORDER BY A.Col1
0
source to share