日期:2014-05-16 浏览次数:20554 次
----------------------------------------------------------------
-- Author :DBA_HuangZJ(发粪涂墙)
-- Date :2014-03-25 16:18:09
-- Version:
-- Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)
-- Apr 2 2010 15:48:46
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([id] nvarchar(22),[ddate] datetime,[num] int)
insert [huang]
select '0010400785','2014-01-12',1 union all
select '0010400785','2014-01-13',2 union all
select '0010400785','2014-01-14',1 union all
select '0010400785','2014-01-18',1 union all
select '0010400785N','2014-01-03',1 union all
select '0010400785N','2014-01-11',2 union all
select '0010400785N','2014-01-13',1 union all
select&