日期:2014-05-17 浏览次数:20625 次
if object_id('[销售表]') is not null drop table [销售表]
go
create table [销售表] (id int,车架号 nvarchar(14),销售金额 int,销售时间 datetime,销售员 nvarchar(4))
insert into [销售表]
select 1,'LVGB123',1980,'2012-09-02 17:42:57.000','张三' union all
select 2,'LVGB545',2980,'2012-09-12 11:42:57.000','李四' union all
select 4,'LVGB623',1980,'2012-09-23 13:42:57.000','张三' union all
select 5,'LVGB532',2980,'2012-09-25 14:42:57.000','王五' union all
select 8,'LVGB234',2980,'2012-09-26 15:42:57.000','王五' union all
select 10,'LVGB623',1980,'2012-09-27 13:42:57.000','李四'
if object_id('[充值表]') is not null drop table [充值表]
go
create table [充值表] (id int,车架号 nvarchar(14),充值金额 int,充值时间 datetime,销售员 nvarchar(4),次数 sql_variant)
insert into [充值表]
select 1,'LVGB123',1980,'2012-09-06 17:42:57.000','张三',null union all
select 2,'LVGB545',2980,'2012-09-15 11:42:57.000','李四',null union all
select 4,'LVGB623',1980,'2012-09-26 13:42:57.000','张三',null union all
select 5,'LVGB532',-2980,'2012-09-27 14:42:57.000','王五',null union all
select 8,'LVGB234',2980,'2012-09-28 15:42:57.000','王五',null union all
select 10,'LVGB623',1980,'2012-09-28 13:42:57.000','王五',null
select * from [销售表]
select * from [充值表]
WITH TT