日期:2014-05-17 浏览次数:20733 次
----------------------------
-- Author :TravyLee(物是人非事事休,欲语泪先流!)
-- Date :2012-12-27 14:26:45
-- Version:
-- Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
-- Jul 9 2008 14:43:34
-- Copyright (c) 1988-2008 Microsoft Corporation
-- Developer Edition on Windows NT 6.1 <X86> (Build 7601: Service Pack 1)
--
----------------------------
--> 测试数据:[test]
if object_id('[test]') is not null
drop table [test]
go
create table [test]
(
[T_CarID] int,
[T_dateTime] datetime,
[T_Status] int
)
insert [test]
select 1,'2012-11-28 00:00:12.000',0 union all
select 1,'2012-11-28 00:00:27.000',0 union all
select 1,'2012-11-28 00:00:30.000',0 union all
select 1,'2012-11-28 00:01:02.000',0 union all
select 1,'2012-11-28 00:01:27.000',0 union all
select 1,'2012-11-28 00:01:52.000',1 union all
select 1,'2012-11-28 00:02:17.000',1
go
with T(a)
as(
select 1 union all
select 1 union all
select 1
),m
as(
select a.a