select isnull(a.goodsid,b.goodsid) as 商品编号,
a.goodname as 名称,
isnull(a.good_num,0) as 库存数量,
isnull(b.goodsnum,0) as 借出数量
from 库存表 a full join 借出表 b
on a.GoodsID=b.GoodsId
a.goodname as 名称,
isnull(a.good_num,0) as 库存数量,
isnull(b.goodsnum,0) as 借出数量
from 库存表 a full join 借出表 b
on a.GoodsID=b.GoodsId
Lsxaa方法差不多可行,我去试.
呵呵.
hdhai9451(※★開拓者...前進☆※) 只是个大致的数据嘛.还有单位啊,型号一类的东西呢,都给出来谁还看啊.
我刚才用Cross(我不知是干啥的),我以为它是外关联,可是不让我用ON,所以我就晕了.
select isnull(A.goods_id,B.goods_id) as goods_id,isnull(A.goods_name,B.goods_name) as goods_name,
isnull(A.spec,B.spec) as Spec,isnull(A.goodstype_id,B.goodstype_id) as goodsType_id,
isnull(A.parent_type,b.parent_type) as parent_type,isnull(A.ware_id,B.ware_id) as ware_id,
isnull(A.store_num,0) as store_num,isnull(B.borrow_num,0) as borrow_num
from Wu_V_StoreSum A full join Wu_V_borrowSum B
on A.goods_id=B.goods_id我用视图,先对库存的和借出的按商品编号对数量进行了汇总,然后再这样FullJoin,之后再加上Where条件过滤,对于效率来说我的做法正确吗?
然后把过滤后的数据直接FullJoin起来.
可是我现在的做法是先汇总,再过滤!这两种方案大家会选哪种呢?