Reputation: 1
I have the following tables:
main_table
stu_name
stu_mark
mark_table
s_name
pos_mark
neg_mark
With data:
main_table
stu_name stu_mark
-------- --------
Rob 20
sally -10
Dave 30
Merve -50
Desired Output:
mark_table
s_name pos_mark neg_mark
------- -------- --------
Rob 20 NULL
Sally NULL -10
Dave 30 NULL
Merve NULL -5
Upvotes: 0
Views: 80
Reputation:
Try:
INSERT INTO mark_table
select stu_name s_name,
case when stu_mark >= 0 then stu_mark end pos_mark,
case when stu_mark < 0 then stu_mark end neg_mark
from main_table
(Assuming you want marks of 0 to be populated in the pos_mark but not the neg_mark column.)
Upvotes: 1