你表B没有单价,那就必须写个函数
create function getje(@bh nvarchar(10))
returns decimal(10,2)
as
begin
declare @je decimal(10,2)
select @je=数量*(select 单价 from 表a where 编号 = @bh)
from 表b where 编号 = @bh
return @je
end
然后你在“总金额”字段下面的公式那里输入dbo.getje(编号)
create function getje(@bh nvarchar(10))
returns decimal(10,2)
as
begin
declare @je decimal(10,2)
select @je=数量*(select 单价 from 表a where 编号 = @bh)
from 表b where 编号 = @bh
return @je
end
然后你在“总金额”字段下面的公式那里输入dbo.getje(编号)
用下面的语句即可
select a.编号,a.单价,b.数量,isnull(a.单价,0)*isnull(b.数量,0) as 总金额
from table1 a inner join table2 b
on a.编号=b.编号