create table A(fee_value money,service_type int) insert A select 50,'2' union all select 10,'3' union all select 40,'4'create table B(service_type int,fee_type int) insert B select'2','0' union all select'2','1' union all select'4','0'select sum(fee_value )fee_value from A,B where A.service_type=B.service_type and fee_type='0'结果 fee_value 90.0000
insert A
select 50,'2'
union all
select 10,'3'
union all
select 40,'4'create table B(service_type int,fee_type int)
insert B
select'2','0'
union all
select'2','1'
union all
select'4','0'select sum(fee_value )fee_value from A,B
where A.service_type=B.service_type
and fee_type='0'结果
fee_value
90.0000