把调试环境也贴上来吧!
程序代码:
--创建销售表:arook_A
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[arook_A]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[arook_A]
GO
CREATE TABLE [dbo].[arook_A] (
[日期] [smalldatetime] NULL ,
[名称] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[销售价] [decimal](18, 2) NULL
) ON [PRIMARY]
GO
--给销售表添加数据
insert into arook_A values('2011-5-18','苹果',5.38)
insert into arook_A values('2012-10-6','香蕉',3.55)
insert into arook_A values('2011-7-22','梨子',4.5)
insert into arook_A values('2010-6-2','草莓',7.5)
--创建采购表:arook_B
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[arook_B]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[arook_B]
GO
CREATE TABLE [dbo].[arook_B] (
[日期] [smalldatetime] NULL ,
[名称] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[采购价] [decimal](18, 2) NULL
) ON [PRIMARY]
GO
--给采购表添加数据
insert into arook_B values('2012-10-1','香蕉',3)
insert into arook_B values('2011-5-13','苹果',4.2)
insert into arook_B values('2012-10-7','香蕉',3.6)
insert into arook_B values('2011-4-11','苹果',3.8)
insert into arook_B values('2011-4-26','梨子',4.1)
insert into arook_B values('2011-5-1','苹果',3.7)
insert into arook_B values('2010-6-1','草莓',6.8)
insert into arook_B values('2011-7-20','梨子',3.9)
insert into arook_B values('2010-5-3','草莓',7.1)
----创建利润表:arook_C
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[arook_C]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[arook_C]
GO
CREATE TABLE [dbo].[arook_C] (
[日期] [smalldatetime] NULL ,
[名称] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[销售价] [decimal](18, 2) NULL ,
[采购价] [decimal](18, 2) NULL ,
[毛利润] [decimal](18, 2) NULL ,
[采购日期] [smalldatetime] NULL
) ON [PRIMARY]
GO