I have these two tables:
SQL> SELECT * FROM TAB_A;
MYDATE P4 D1 D2 P5 P6
--------- ---------- ---------- ----------- ----------- -----------
30-OCT-12 949,324 4,437,654 10,203,116 25,303,632 13,900,078
SQL> SELECT * FROM TAB_B;
MYDATE P4 D1 D2 P5 P6
--------- ---------- ---------- ----------- ----------- -----------
30-OCT-12 937,796 4,388,477 10,091,811 25,028,402 13,755,882
I need to subtract their respective columns and store the results into a third table like so:
SQL> INSERT INTO TAB_C (MYDATE, P4) SELECT SYSDATE,A.P4-B.P4 FROM TAB_A A,TAB_B B WHERE A.MYDATE=B.MYDATE;
SQL> SELECT * FROM TAB_C;
MYDATE P4 D1 D2 P5 P6
--------- ---------- ---------- ----------- ----------- -----------
30-OCT-12 926,268
The result is wrong. Basic math: 949324-937796=11528. Numeric values are stored as number datatypes. What am I missing here?