oracle 9i full join 问题
ib915 2005-01-28 10:15:35 money_book 为视图
==============================================
select nvl(a.customer_no,b.customer_no),NVL(a.total,b.total) from
(select customer_no,sum(total_amount) as total from money_book where total_amount>0 group by customer_no) a
full join
(select customer_no,sum(total_amount) as total from money_book where total_amount<0 group by customer_no ) b
on a.customer_no=b.customer_no;
运行:
NVL(A.CUSTOMER_NO,B.CUSTOMER_NO) NVL(A.TOTAL,B.TOTAL)
-------------------------------- --------------------
7 200
已选择 1 行。
======================================
两表分开运行其中a
select customer_no,sum(total_amount) as total from money_book where total_amount>0 group by customer_no
CUSTOMER_NO TOTAL
----------- ----------
7 200
已选择 1 行。
其中 b
select customer_no,sum(total_amount) as total from money_book where total_amount<0 group by customer_no
CUSTOMER_NO TOTAL
----------- ----------
2 -480
已选择 1 行。
为什么full join 后只有一条纪录。我试过自己建两表a,b 数据一样,full join 后有两条纪录,
是否关视图问题??压抑