2010-03-08 17:10:42.403 2010-03-08 17:10:44.437
2010-03-08 17:40:47.827 2010-03-08 17:40:49.483
2010-03-08 23:59:17.857 2010-03-08 23:59:25.467
2010-03-09 01:36:27.700 2010-03-09 01:36:29.043
2010-03-09 02:12:28.873 2010-03-09 02:12:30.060
2010-03-09 02:30:37.840 2010-03-09 02:30:39.060
2010-03-09 02:43:26.483 2010-03-09 02:43:28.187
2010-03-09 03:06:04.403 2010-03-09 03:06:06.013
2010-03-09 03:24:42.890 2010-03-09 03:24:44.403
2010-03-09 03:41:46.500 2010-03-09 03:41:48.090
2010-03-09 06:22:21.937 2010-03-09 06:22:23.263
2010-03-09 06:22:24.687 2010-03-09 06:22:26.780用前一行的日期减后一行的日期 该怎么写啊?

解决方案 »

  1.   


    --> 测试数据:[TB]
    if object_id('[TB]') is not null drop table [TB]
    create table [TB]([A] datetime,[B] datetime)
    insert [TB]
    select '2010-03-08 17:10:42.403','2010-03-08 17:10:44.437' union all
    select '2010-03-08 17:40:47.827','2010-03-08 17:40:49.483' union all
    select '2010-03-08 23:59:17.857','2010-03-08 23:59:25.467' union all
    select '2010-03-09 01:36:27.700','2010-03-09 01:36:29.043' union all
    select '2010-03-09 02:12:28.873','2010-03-09 02:12:30.060' union all
    select '2010-03-09 02:30:37.840','2010-03-09 02:30:39.060' union all
    select '2010-03-09 02:43:26.483','2010-03-09 02:43:28.187' union all
    select '2010-03-09 03:06:04.403','2010-03-09 03:06:06.013' union all
    select '2010-03-09 03:24:42.890','2010-03-09 03:24:44.403' union all
    select '2010-03-09 03:41:46.500','2010-03-09 03:41:48.090' union all
    select '2010-03-09 06:22:21.937','2010-03-09 06:22:23.263' union all
    select '2010-03-09 06:22:24.687','2010-03-09 06:22:26.780'select A-B from [TB]/*-----------------------
    1899-12-31 23:59:57.967
    1899-12-31 23:59:58.343
    1899-12-31 23:59:52.390
    1899-12-31 23:59:58.657
    1899-12-31 23:59:58.813
    1899-12-31 23:59:58.780
    1899-12-31 23:59:58.297
    1899-12-31 23:59:58.390
    1899-12-31 23:59:58.487
    1899-12-31 23:59:58.410
    1899-12-31 23:59:58.673
    1899-12-31 23:59:57.907(12 行受影响)*/drop table TB
      

  2.   

    利用IDENTITY(INT,1,1) AS ID来
    ID=ID-1
      

  3.   

    select A-B from [TB]这好像是列吧?