I am learning to use SQL. I have two tables Table1 and Table2. I need to fetch three columns from Table1 say A,B,C and add them as A,B and C on table2. also perform arithmetic operation on Column D and E using Column C on table2.
insert into Table2(A,B,C)
select(A,B,C ) from Table1.
Now how do I do the arithmetic calculation on column D and E on table 2. It goes like this C*5 as D
and c*10 as E
Any help here Is highly appreciated
I assume this is what you want:
insert into Table2 (A,B,C,D,E) select A,B,C,5*C,10*C from Table1
You might consider using a view instead of a table:
create view V2 as ( select A, B, C, 5*C as D, 10*C as E from Table1 )
Unless you are using D and E in predicates, there should not be much performance penalty.