原数据ID   日期        安排产量      机台
1    2008/4/14    100          #1
2    2008/4/16    80           #1
3    2008/6/14    300          #1
4    2008/6/24    200          #2
5    2009/2/14    50           #1说明:日期自动的值大于等于今天, 它所遍布的月份和周份不固定想得到下面结果(1): 按未来一年统计机台   月份     安排产量
#1     2008/4    180
#1     2008/5    0
#1     2008/6    300
#1     2008/7    0
#1     2008/8    0
#1     2008/9    0
#1     2008/10    0
#1     2008/11    0
#1     2008/12    0
#1     2009/1    0
#1     2009/2    50
#1     2009/3    0
#2     2008/4    0
#2     2008/5    0
#2     2008/6    200
#2     2008/7    0
#2     2008/8    0
#2     2008/9    0
#2     2008/10    0
#2     2008/11    0
#2     2008/12    0
#2     2009/1    0
#2     2009/2    0
#2     2009/3    0想得到下面结果(1): 按未来10周统计
机台   月份     安排产量
#1     2008/4/14   180     (也就是4/14至4/21这一周安排的产量,统计未来10周)
#1     2008/4/21    0
#1     2008/4/21    0
....            

解决方案 »

  1.   

    create table tb(ID int, 日期 datetime, 安排产量 int, 机台 varchar(10))
    insert into tb values(1 , '2008/4/14' , 100 , '#1') 
    insert into tb values(2 , '2008/4/16' , 80 , '#1') 
    insert into tb values(3 , '2008/6/14' , 300 , '#1') 
    insert into tb values(4 , '2008/6/24' , 200 , '#2') 
    insert into tb values(5 , '2009/2/14' , 50 , '#1')
    goSELECT TOP 8000 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b  select t1.机台 , t1.月份 , isnull(t2.安排产量,0) 安排产量 from
    (
      select o.机台 , 月份 = convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) from 
      (select min(convert(varchar(10),日期,120)) minmonth from tb) m,
      (select max(convert(varchar(10),日期,120)) minmonth from tb) n,
      tmp , (select distinct 机台 from tb) o
      where convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) <= convert(varchar(7),n.minmonth,120)
    ) t1 left join 
    (
      select 机台 , convert(varchar(7),日期,120) 月份 , sum(安排产量) 安排产量 from tb group by 机台 , convert(varchar(7),日期,120)
    ) t2
    on t1.机台 = t2.机台 and t1.月份 = t2.月份
    order by t1.机台 , t1.月份drop table tb,tmp/*
    机台         月份      安排产量        
    ---------- ------- ----------- 
    #1         2008-04 180
    #1         2008-05 0
    #1         2008-06 300
    #1         2008-07 0
    #1         2008-08 0
    #1         2008-09 0
    #1         2008-10 0
    #1         2008-11 0
    #1         2008-12 0
    #1         2009-01 0
    #1         2009-02 50
    #2         2008-04 0
    #2         2008-05 0
    #2         2008-06 200
    #2         2008-07 0
    #2         2008-08 0
    #2         2008-09 0
    #2         2008-10 0
    #2         2008-11 0
    #2         2008-12 0
    #2         2009-01 0
    #2         2009-02 0(所影响的行数为 22 行)
    */
      

  2.   

    --你还要多加一个月为0的数据?
    create table tb(ID int, 日期 datetime, 安排产量 int, 机台 varchar(10))
    insert into tb values(1 , '2008/4/14' , 100 , '#1') 
    insert into tb values(2 , '2008/4/16' , 80 , '#1') 
    insert into tb values(3 , '2008/6/14' , 300 , '#1') 
    insert into tb values(4 , '2008/6/24' , 200 , '#2') 
    insert into tb values(5 , '2009/2/14' , 50 , '#1')
    go--创建一辅助表
    SELECT TOP 8000 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b  select t1.机台 , t1.月份 , isnull(t2.安排产量,0) 安排产量 from
    (
      select o.机台 , 月份 = convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) from 
      (select min(convert(varchar(10),日期,120)) minmonth from tb) m,
      (select max(convert(varchar(10),dateadd(mm,1,日期),120)) minmonth from tb) n,
      tmp , (select distinct 机台 from tb) o
      where convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) <= convert(varchar(7),n.minmonth,120)
    ) t1 left join 
    (
      select 机台 , convert(varchar(7),日期,120) 月份 , sum(安排产量) 安排产量 from tb group by 机台 , convert(varchar(7),日期,120)
    ) t2
    on t1.机台 = t2.机台 and t1.月份 = t2.月份
    order by t1.机台 , t1.月份drop table tb,tmp/*
    机台         月份      安排产量        
    ---------- ------- ----------- 
    #1         2008-04 180
    #1         2008-05 0
    #1         2008-06 300
    #1         2008-07 0
    #1         2008-08 0
    #1         2008-09 0
    #1         2008-10 0
    #1         2008-11 0
    #1         2008-12 0
    #1         2009-01 0
    #1         2009-02 50
    #1         2009-03 0
    #2         2008-04 0
    #2         2008-05 0
    #2         2008-06 200
    #2         2008-07 0
    #2         2008-08 0
    #2         2008-09 0
    #2         2008-10 0
    #2         2008-11 0
    #2         2008-12 0
    #2         2009-01 0
    #2         2009-02 0
    #2         2009-03 0(所影响的行数为 24 行)
    */
      

  3.   

    --不好意思,现在才明白,是按未来一年来计算.
    create table tb(ID int, 日期 datetime, 安排产量 int, 机台 varchar(10))
    insert into tb values(1 , '2008/4/14' , 100 , '#1') 
    insert into tb values(2 , '2008/4/16' , 80 , '#1') 
    insert into tb values(3 , '2008/6/14' , 300 , '#1') 
    insert into tb values(4 , '2008/6/24' , 200 , '#2') 
    insert into tb values(5 , '2009/2/14' , 50 , '#1')
    goSELECT TOP 8000 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b  select t1.机台 , t1.月份 , isnull(t2.安排产量,0) 安排产量 from
    (
      select o.机台 , 月份 = convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) from 
      (select min(convert(varchar(10),日期,120)) minmonth from tb) m,
      tmp , (select distinct 机台 from tb) o
      where convert(varchar(7),dateadd(mm , tmp.id , m.minmonth),120) <= convert(varchar(7),dateadd(mm,11,m.minmonth),120)
    ) t1 left join 
    (
      select 机台 , convert(varchar(7),日期,120) 月份 , sum(安排产量) 安排产量 from tb group by 机台 , convert(varchar(7),日期,120)
    ) t2
    on t1.机台 = t2.机台 and t1.月份 = t2.月份
    order by t1.机台 , t1.月份drop table tb,tmp/*
    机台         月份      安排产量        
    ---------- ------- ----------- 
    #1         2008-04 180
    #1         2008-05 0
    #1         2008-06 300
    #1         2008-07 0
    #1         2008-08 0
    #1         2008-09 0
    #1         2008-10 0
    #1         2008-11 0
    #1         2008-12 0
    #1         2009-01 0
    #1         2009-02 50
    #1         2009-03 0
    #2         2008-04 0
    #2         2008-05 0
    #2         2008-06 200
    #2         2008-07 0
    #2         2008-08 0
    #2         2008-09 0
    #2         2008-10 0
    #2         2008-11 0
    #2         2008-12 0
    #2         2009-01 0
    #2         2009-02 0
    #2         2009-03 0(所影响的行数为 24 行)
    */
      

  4.   

    create table ta(ID int,日期  datetime,安排产量  int,机台 varchar(10))
    insert ta select
    1    ,'2008/4/14',    100          ,'#1' union select 
    2    ,'2008/4/16',    80           ,'#1' union select 
    3    ,'2008/6/14',    300          ,'#1' union select 
    4    ,'2008/6/24',    200          ,'#2' union select 
    5    ,'2009/2/14',    50           ,'#1'
    go
    select c.机台,sum(isnull(a.安排产量,0)) as 安排产量 ,convert(char(7),dateadd(mm,c.id,'2008-01-01'),120) rq
    from ta a
    right join
    ( select 机台,b.id
    from (select distinct 机台 from ta) a,
    (select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6
    union select 7 union select 8 union select 9 union select 10 union select 11 union select 0) b
    ) con  a.机台 = c.机台 and datepart(mm,日期) = c.id + 1group by c.机台,c.iddrop table ta 
    /*
    机台         安排产量        rq      
    ---------- ----------- ------- 
    #1         0           2008-01
    #1         50          2008-02
    #1         0           2008-03
    #1         180         2008-04
    #1         0           2008-05
    #1         300         2008-06
    #1         0           2008-07
    #1         0           2008-08
    #1         0           2008-09
    #1         0           2008-10
    #1         0           2008-11
    #1         0           2008-12
    #2         0           2008-01
    #2         0           2008-02
    #2         0           2008-03
    #2         0           2008-04
    #2         0           2008-05
    #2         200         2008-06
    #2         0           2008-07
    #2         0           2008-08
    #2         0           2008-09
    #2         0           2008-10
    #2         0           2008-11
    #2         0           2008-12(所影响的行数为 24 行)
    */
      

  5.   

    --未来十周
    create table tb(ID int, 日期 datetime, 安排产量 int, 机台 varchar(10))
    insert into tb values(1 , '2008/4/14' , 100 , '#1') 
    insert into tb values(2 , '2008/4/16' , 80 , '#1') 
    insert into tb values(3 , '2008/6/14' , 300 , '#1') 
    insert into tb values(4 , '2008/6/24' , 200 , '#2') 
    insert into tb values(5 , '2009/2/14' , 50 , '#1')
    goSELECT TOP 8000 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b  
    select t1.机台 , t1.周 , isnull(t2.安排产量,0) 安排产量 from
    (
      select o.机台 , 周 = convert(varchar(10),DATEADD(wk,DATEDIFF(wk,0,convert(varchar(10),dateadd(week , tmp.id , m.minmonth),120)),0),120) from 
      (select min(convert(varchar(10),日期,120)) minmonth from tb) m,
      tmp , (select distinct 机台 from tb) o
      where convert(varchar(10),dateadd(week , tmp.id , m.minmonth),120) <= dateadd(week,10,m.minmonth)
    ) t1
    left join 
    (
      select 周一 = convert(varchar(10),DATEADD(wk,DATEDIFF(wk,0,日期),0),120) , 机台 , 安排产量 = sum(安排产量) from tb group by 机台 , convert(varchar(10),DATEADD(wk,DATEDIFF(wk,0,日期),0),120) 
    ) t2
    on t1.机台 = t2.机台 and t1.周 = t2.周一drop table tb,tmp/*
    机台         周          安排产量        
    ---------- ---------- ----------- 
    #1         2008-04-14 180
    #2         2008-04-14 0
    #1         2008-04-21 0
    #2         2008-04-21 0
    #1         2008-04-28 0
    #2         2008-04-28 0
    #1         2008-05-05 0
    #2         2008-05-05 0
    #1         2008-05-12 0
    #2         2008-05-12 0
    #1         2008-05-19 0
    #2         2008-05-19 0
    #1         2008-05-26 0
    #2         2008-05-26 0
    #1         2008-06-02 0
    #2         2008-06-02 0
    #1         2008-06-09 300
    #2         2008-06-09 0
    #1         2008-06-16 0
    #2         2008-06-16 0
    #1         2008-06-23 0
    #2         2008-06-23 200(所影响的行数为 22 行)
    */
      

  6.   

    create table ta(ID int,日期  datetime,安排产量  int,机台 varchar(10))
    insert ta select
    1    ,'2008/4/14',    100          ,'#1' union select 
    2    ,'2008/4/16',    80           ,'#1' union select 
    3    ,'2008/6/14',    300          ,'#1' union select 
    4    ,'2008/6/24',    200          ,'#2' union select 
    5    ,'2009/2/14',    50           ,'#1'
    goSELECT TOP 10 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b 
    declare @i int
    set @i = datepart(wk,getdate())
    select c.机台,sum(isnull(a.安排产量,0)) as 安排产量 ,c.id+1 [末来week],dateadd(d,(c.id -1)* 7 -1,'2008-01-01') rq
    from ta a
    right join
    (
        select 机台,b.id
    from (select distinct 机台 from ta) a,
    (select id   as id from tmp) b
    ) con  a.机台 = c.机台 and datepart(wk,日期) - @i = c.id group by c.机台,c.idorder by c.机台,c.iddrop table ta ,tmp
    /*
    (所影响的行数为 5 行)
    (所影响的行数为 10 行)机台         安排产量        末来week      rq                                                     
    ---------- ----------- ----------- ------------------------------------------------------ 
    #1         180         1           2007-12-24 00:00:00.000
    #1         0           2           2007-12-31 00:00:00.000
    #1         0           3           2008-01-07 00:00:00.000
    #1         0           4           2008-01-14 00:00:00.000
    #1         0           5           2008-01-21 00:00:00.000
    #1         0           6           2008-01-28 00:00:00.000
    #1         0           7           2008-02-04 00:00:00.000
    #1         0           8           2008-02-11 00:00:00.000
    #1         300         9           2008-02-18 00:00:00.000
    #1         0           10          2008-02-25 00:00:00.000
    #2         0           1           2007-12-24 00:00:00.000
    #2         0           2           2007-12-31 00:00:00.000
    #2         0           3           2008-01-07 00:00:00.000
    #2         0           4           2008-01-14 00:00:00.000
    #2         0           5           2008-01-21 00:00:00.000
    #2         0           6           2008-01-28 00:00:00.000
    #2         0           7           2008-02-04 00:00:00.000
    #2         0           8           2008-02-11 00:00:00.000
    #2         0           9           2008-02-18 00:00:00.000
    #2         0           10          2008-02-25 00:00:00.000(所影响的行数为 20 行)
    */
      

  7.   

    --SELECT TOP 8000 id 
    这个8000表示什么?
      

  8.   

    这个8000是随便取的一个,按你的要求,只需要12个即可.(就是个可能要用到的最大的数量)就是:select TOP 12 id  
      

  9.   

    机台         安排产量        rq      
    ---------- ----------- ------- 
    #1         0           2008-01
    #1         50          2008-02未来怎么跑到1月份(所影响的行数为 10 行)机台         安排产量        末来week      rq                                                     
    ---------- ----------- ----------- ------------------------------------------------------ 
    #1         180         1           2007-12-24 00:00:00.000
    #1         0           2           2007-12-31 00:00:00.000未来怎么跑到07年
      

  10.   

    create table ta(ID int,日期  datetime,安排产量  int,机台 varchar(10))
    insert ta select
    1    ,'2008/4/14',    100          ,'#1' union select 
    2    ,'2008/4/16',    80           ,'#1' union select 
    3    ,'2008/6/14',    300          ,'#1' union select 
    4    ,'2008/6/24',    200          ,'#2' union select 
    5    ,'2009/2/14',    50           ,'#1'
    goSELECT TOP 10 id = identity(int,0,1) INTO tmp FROM syscolumns a, syscolumns b 
    declare @i int
    set @i = datepart(wk,getdate())
    select c.机台,sum(isnull(a.安排产量,0)) as 安排产量 ,c.id [末来week],DATEADD(wk,  DATEDIFF(wk,-c.id * 7,getdate()),  0) rq
    from ta a
    right join
    (
        select 机台,b.id
    from (select distinct 机台 from ta) a,
    (select id   as id from tmp) b
    ) con  a.机台 = c.机台 and datepart(wk,日期) - @i = c.id group by c.机台,c.idorder by c.机台,c.iddrop table ta ,tmp
    /*
    (所影响的行数为 5 行)
    (所影响的行数为 10 行)机台         安排产量        末来week      rq                                                     
    ---------- ----------- ----------- ------------------------------------------------------ 
    #1         180         0           2008-04-14 00:00:00.000
    #1         0           1           2008-04-21 00:00:00.000
    #1         0           2           2008-04-28 00:00:00.000
    #1         0           3           2008-05-05 00:00:00.000
    #1         0           4           2008-05-12 00:00:00.000
    #1         0           5           2008-05-19 00:00:00.000
    #1         0           6           2008-05-26 00:00:00.000
    #1         0           7           2008-06-02 00:00:00.000
    #1         300         8           2008-06-09 00:00:00.000
    #1         0           9           2008-06-16 00:00:00.000
    #2         0           0           2008-04-14 00:00:00.000
    #2         0           1           2008-04-21 00:00:00.000
    #2         0           2           2008-04-28 00:00:00.000
    #2         0           3           2008-05-05 00:00:00.000
    #2         0           4           2008-05-12 00:00:00.000
    #2         0           5           2008-05-19 00:00:00.000
    #2         0           6           2008-05-26 00:00:00.000
    #2         0           7           2008-06-02 00:00:00.000
    #2         0           8           2008-06-09 00:00:00.000
    #2         0           9           2008-06-16 00:00:00.000(所影响的行数为 20 行)
    */
      

  11.   

    具体数量自己选择就行了.dateadd(week,10,m.minmonth)
    dateadd(week,9,m.minmonth)
      

  12.   

    机台         安排产量        末来week      rq                                                     rq2                                                    
    ---------- ----------- ----------- ------------------------------------------------------ ------------------------------------------------------ 
    #1         180         1           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #1         0           2           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #1         0           3           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #1         0           4           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #1         0           5           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #1         0           6           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #1         0           7           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #1         0           8           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #1         300         9           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000
    #2         0           1           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #2         0           2           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #2         0           3           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #2         0           4           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #2         0           5           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #2         0           6           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #2         0           7           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #2         0           8           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #2         0           9           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000(所影响的行数为 18 行)
      

  13.   

    create table ta(ID int,日期  datetime,安排产量  int,机台 varchar(10))
    insert ta select
    1    ,'2008/4/14',    100          ,'#1' union select 
    2    ,'2008/4/16',    80           ,'#1' union select 
    3    ,'2008/6/14',    300          ,'#1' union select 
    4    ,'2008/6/24',    200          ,'#2' union select 
    5    ,'2009/2/14',    50           ,'#1'
    go
    select c.机台,sum(isnull(a.安排产量,0)) as 安排产量 ,
    c.id [末来week],DATEADD(wk,  DATEDIFF(wk,-(c.id-1) * 7,getdate()),  0) rq,
    DATEADD(wk,  DATEDIFF(wk,-c.id * 7,getdate()),  0) rq2
    from ta a
    right join
    (    
        select 机台,b.id
        from (select distinct 机台 from ta) a,
        (select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6
        union select 7 union select 8 union select 9) b
    ) con  a.机台 = c.机台 and 日期 between DATEADD(wk,  DATEDIFF(wk,-(c.id -1)* 7,getdate()),  0)  and DATEADD(wk,  DATEDIFF(wk,-c.id * 7,getdate()),  0)group by c.机台,c.idorder by c.机台,c.iddrop table ta/*
    机台         安排产量        末来week      rq                                                     rq2                                                    
    ---------- ----------- ----------- ------------------------------------------------------ ------------------------------------------------------ 
    #1         180         1           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #1         0           2           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #1         0           3           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #1         0           4           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #1         0           5           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #1         0           6           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #1         0           7           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #1         0           8           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #1         300         9           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000
    #2         0           1           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #2         0           2           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #2         0           3           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #2         0           4           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #2         0           5           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #2         0           6           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #2         0           7           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #2         0           8           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #2         0           9           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000(所影响的行数为 18 行)
    */
      

  14.   

    更正一下:
    引用 23 楼 weisai 的回复:
    不用考虑周日,只是从今天算起7天算一周(或者说是一个考察的时段),和一般的周没有联系 
    create table ta(ID int,日期  datetime,安排产量  int,机台 varchar(10))
    insert ta select
    1    ,'2008/4/14',    100          ,'#1' union select 
    2    ,'2008/4/16',    80           ,'#1' union select 
    3    ,'2008/6/14',    300          ,'#1' union select 
    4    ,'2008/6/24',    200          ,'#2' union select 
    5    ,'2009/2/14',    50           ,'#1'
    go
    select c.机台,sum(isnull(a.安排产量,0)) as 安排产量 ,
    c.id [末来week],DATEADD(wk,  DATEDIFF(wk,-c.id * 7,getdate()),  0) rq,
    DATEADD(wk,  DATEDIFF(wk,-(c.id+1) * 7,getdate()),  0) rq2
    from ta a
    right join
    (    
        select 机台,b.id
        from (select distinct 机台 from ta) a,
        (select 1 as id union select 2 union select 3 union select 4 union select 5 union select 6
        union select 7 union select 8 union select 9 union select 0) b
    ) con  a.机台 = c.机台 and 日期 between DATEADD(wk,  DATEDIFF(wk,-c.id* 7,getdate()),  0)  and DATEADD(wk,  DATEDIFF(wk,-(c.id+1) * 7,getdate()),  0)group by c.机台,c.idorder by c.机台,c.iddrop table ta/*
    机台         安排产量        末来week      rq                                                     rq2                                                    
    ---------- ----------- ----------- ------------------------------------------------------ ------------------------------------------------------ 
    #1         180         0           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #1         0           1           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #1         0           2           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #1         0           3           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #1         0           4           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #1         0           5           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #1         0           6           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #1         0           7           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #1         300         8           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000
    #1         0           9           2008-06-16 00:00:00.000                                2008-06-23 00:00:00.000
    #2         0           0           2008-04-14 00:00:00.000                                2008-04-21 00:00:00.000
    #2         0           1           2008-04-21 00:00:00.000                                2008-04-28 00:00:00.000
    #2         0           2           2008-04-28 00:00:00.000                                2008-05-05 00:00:00.000
    #2         0           3           2008-05-05 00:00:00.000                                2008-05-12 00:00:00.000
    #2         0           4           2008-05-12 00:00:00.000                                2008-05-19 00:00:00.000
    #2         0           5           2008-05-19 00:00:00.000                                2008-05-26 00:00:00.000
    #2         0           6           2008-05-26 00:00:00.000                                2008-06-02 00:00:00.000
    #2         0           7           2008-06-02 00:00:00.000                                2008-06-09 00:00:00.000
    #2         0           8           2008-06-09 00:00:00.000                                2008-06-16 00:00:00.000
    #2         0           9           2008-06-16 00:00:00.000                                2008-06-23 00:00:00.000(所影响的行数为 20 行)
    */
      

  15.   

    哈哈,现在是6月份,大家把各种的SQL执行以下,会发现4,5月底数据还在,这已经是过去的数据了