注册 登录
编程论坛 SQL Server论坛

两句合并成一句

bhffhzh 发布于 2018-10-15 21:41, 2029 次点击
Set hzhadd = conn.Execute("select  sum(jnum) from bonus_points b where     b.ptype=3  and b.jgrade='2013' and b.jclass='1'  ")
Set hzhdec = conn.Execute("select  sum(knum)*-1  from bonus_points b where     b.ptype=1  and b.kgrade='2013' and b.kclass='1'  ")



请问如何合并成一句话.>?
3 回复
#2
林月儿2018-10-15 22:48
union还是加和?
#3
bhffhzh2018-10-18 19:15
加和
#4
林月儿2018-10-23 15:15
select sum(s) from (select sum(col1)s from table1
union select sum(col2)s from table2) a
1