#2
mywisdom882018-11-15 19:13
|
SELECT 000 as 序号, a.编号, a.名称, a.规格, a.期初数量,
cast( b.数量 as int) as 入库数量,cast(c.总数量 as int) as 出库数量,cast(a.期初数量+isnull(b.数量,0)-isnull(c.总数量,0) as int) as 当前库存
FROM dbo.b_产品 as a
left join(select 产品id,sum(数量) as 数量 from dbo.r_产品入库表 group by 产品id ) as b on a.id = b.产品id
left join (select 产品id,sum(总数量) as 总数量 from dbo.x_销售表 group by 产品id) as c ON b.产品id = c.产品id
请问在sql server中用上面语句进行视图查询,对于数据量大的表(几十万)执行效率如何?