日期:2014-05-17 浏览次数:20440 次
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-01-15 23:34:06
-- Version:
-- Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (Intel X86)
-- Jun 17 2011 00:57:23
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
--
----------------------------
--> 测试数据:[表A]
if object_id('[表A]') is not null drop table [表A]
go
create table [表A]([Date] datetime,[BH] int,[Number] int)
insert [表A]
select '2012-12-1',1,10 union all
select '2012-12-1',2,20 union all
select '2012-12-1',3,30 union all
select '2012-12-2',1,10 union all
select '2012-12-2',2,20 union all
select '2012-12-3',1,10
--> 测试数据:[表B]
if object_id('[表B]') is not null drop table [表B]
go
create table [表B]([Date] datetime,[BH] int)
insert [表B]
select '2012-12-1',2 union all
select