表1
F_id F_name F_num F_price F_tprice表2
F_id F_name F_num F_price
1 aaa 2 10
2 ccc 1 12当把表2的记录插入到表1中时,计算出总价。
计算后的结果为:
表1
F_id F_name F_num F_price F_tprice
1 aaa 2 10 20
2 ccc 1 12 12
F_id F_name F_num F_price F_tprice表2
F_id F_name F_num F_price
1 aaa 2 10
2 ccc 1 12当把表2的记录插入到表1中时,计算出总价。
计算后的结果为:
表1
F_id F_name F_num F_price F_tprice
1 aaa 2 10 20
2 ccc 1 12 12
select F_id , F_name , F_num , F_price ,F_num *F_price
from 表2
select F_id,F_name,F_num,F_price,F_num*F_price as F_tprice
from 表2
declare @t table(F_id int,F_name varchar(10),F_num int,F_price int,F_tprice as F_num*F_price)declare @a table(F_id int,F_name varchar(10),F_num int,F_price int)
insert into @a select 1,'aaa',2,10
union all select 2,'ccc',1,12insert into @t select * from @aselect * from @t