Here, I have one Table T1.
In that table, I have one column F1 having some positive and negative values.
I want to display those values in two different columns.
select * from T1
F1
--------
1000
-2000
500
-1000
2000
-300
I want to display like this
Pos Neg
------- ------
1000 -2000
500 -1000
2000 -300
How to do this any suggestion?

Jignesh KumarRank #91 · 22.9K reputationPosted Mar 11, 2019, 7:21 AM EDT
Puneet KankarRank #446 · 5.6K reputationPosted Mar 11, 2019, 8:12 AM EDT
Sujit SahooRank #5,034 · 314 reputationPosted Mar 11, 2019, 9:19 AM EDT
Mubarak Hashmi8 reputationPosted Feb 11, 2022, 11:27 AM EST
Create table sample
(
id int
)
insert into sample values(1000),(-1000),(500),(-2000),(2000),(-300)
select Neg.id as Negetive,Pos.id as Positive
from
(
select *,ROW_NUMBER()over( order by id) rownum from sample
where id<0)Neg
full outer join
(select *,ROW_NUMBER()over( order by id) rownum from sample
where id>=0)Pos
On neg.rownum=pos.rownum
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Feb 11, 2022, 2:06 PM EST
Sachin SinghRank #66 · 26.2K reputationPosted Feb 12, 2022, 12:29 AM EST
MAHAMDSALAM MULLA6 reputationPosted Apr 4, 2022, 3:15 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Apr 4, 2022, 4:05 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts