如何用sum函数求两个表数据的和
周淡 2012-05-17 05:56:06 //我要把当前表和历史表的数据相加求出来,我用了以下sql语句,但是发现求不出来。
SELECT count(pk1) as count1 FROM ftrans_info where user_id='2012050900000001' and tran_code in ('6110','6120','6130')
and tran_date between '2012-01-01' and '2012-05-17' and chk_status = 1 and status = 1
union
SELECT count(pk1) as count2 FROM ftrans_info_hst where user_id='2012050900000001' and tran_code in ('6110','6120','6130') and tran_date
between '2012-01-01' and '2012-05-17' and chk_status = 1 and status = 1
//以下是上述sql语句的输出结果
COUNT1
23
24
我如何把两个sql语句合并成一个输出,就是我的预想输出是
COUNT1
47