table 1
ID Qty completed_qty KEY
1 2 1 a
2 3 1 b
3 4 3 c
table 2
ID Qty completed_qty Percent Priority KEY
1 2 1 50 H a
2 3 1 33.33 L b
3 4 3 75 H c
I has 2 table which I select table 1 and then insert into table 2 using script below
INSERT into table2(Qty, Completed_qty, Percent, KEY)
select Qty, Completed_qty, (completed_qty / Qty) * 100 [Percent], KEY from table1 where
KEY not in (select table2.KEY from table2)
So, when everytime I perform the script, the same record will not copy into table2.
I face a problem when the Percentage from the table1 is change, I want update also the Percent in table 2, I change the script as below but cannot make it.
INSERT into table2(Qty, Completed_qty, Percent, KEY)
select Qty, Completed_qty, (completed_qty / Qty) * 100 [Percent], KEY from table1 where
KEY not in (select table2.KEY from table2)
and (completed_qty / Qty) * 100 <> (select table2.Percent from table2)
I get the error as below:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
Any one as done the similar script before. Any idea how I can done this?