有两个表,一个表里有一个字段,求出这来个字段的总和怎么求? string heji = "select sum( B_aggregate) as sumagg from B_ABinfo ";
string heji1 = "select sum( YB_aggregate) as sumagg from YB_ABinfo ";我怎么给他们都加起来 或者还有其他的办法
string heji1 = "select sum( YB_aggregate) as sumagg from YB_ABinfo ";我怎么给他们都加起来 或者还有其他的办法
)
select B_aggregate as sumagg from B_ABinfo
union all
select YB_aggregate as sumagg from YB_ABinfo
)aa
你只有从数据库中把两个字段值读取出来,赋值到变量,然后相加.
(--错了这个括号
select B_aggregate as sumagg from B_ABinfo
union all
select YB_aggregate as sumagg from YB_ABinfo
)aa
(
select B_aggregate as sumagg from B_ABinfo
union all
select YB_aggregate as sumagg from YB_ABinfo
)aa