use hbposev9 --数据库名
go
--如果存在就先删除视图
if exists(select * from sys.views where name = 'view_name')
drop view view_name
go
--创建视图
CREATE VIEW view_name AS
--查询语句
select a.item_clsno ,a.item_name,b.branch_no
,sum(b.real_qty)as 'APP订单数量',sum(c.real_qty) as '门店要货数量'
from t_bd_item_info a
full join t_order_bill_weixin b on(A.item_no=B.item_no)
full join t_pm_sheet_detail c on(A.item_no=c.item_no)
where (b.real_qty+c.real_qty)<>0
and b.branch_no like '%%'
and c.sheet_no like 'YH%'
group by a.item_clsno,a.item_name,b.branch_no
go
--最后直接就可以查询此视图
select * from view_name
go
--如果存在就先删除视图
if exists(select * from sys.views where name = 'view_name')
drop view view_name
go
--创建视图
CREATE VIEW view_name AS
--查询语句
select a.item_clsno ,a.item_name,b.branch_no
,sum(b.real_qty)as 'APP订单数量',sum(c.real_qty) as '门店要货数量'
from t_bd_item_info a
full join t_order_bill_weixin b on(A.item_no=B.item_no)
full join t_pm_sheet_detail c on(A.item_no=c.item_no)
where (b.real_qty+c.real_qty)<>0
and b.branch_no like '%%'
and c.sheet_no like 'YH%'
group by a.item_clsno,a.item_name,b.branch_no
go
--最后直接就可以查询此视图
select * from view_name