Y yyk518 Unregistered / Unconfirmed GUEST, unregistred user! 2002-06-21 #1 [?]入库表字段: 材料代码,入库数量,入库日期 出库表字段: 材料代码,出库数量,出库日期 请问,我该如何建立一个查阅所有材料库存的视图呢?
特 特尔斐 Unregistered / Unconfirmed GUEST, unregistred user! 2002-11-13 #2 CREATE VIEW dbo.vw AS SELECT dbo.tab_IN.id, SUM(dbo.tab_IN.qty - ISNULL(dbo.tab_OUT.qty, 0)) AS QTY FROM dbo.tab_IN LEFT OUTER JOIN dbo.tab_OUT ON dbo.tab_IN.id = dbo.tab_OUT.id GROUP BY dbo.tab_IN.id
CREATE VIEW dbo.vw AS SELECT dbo.tab_IN.id, SUM(dbo.tab_IN.qty - ISNULL(dbo.tab_OUT.qty, 0)) AS QTY FROM dbo.tab_IN LEFT OUTER JOIN dbo.tab_OUT ON dbo.tab_IN.id = dbo.tab_OUT.id GROUP BY dbo.tab_IN.id