本人初学SQL语言,但是有道题不会,还有SQL如何进行表的转换,思想是什磨????
11、 有表test 
Personcode ttime Iotype
001 8:00 1
001 8:05 1
001 12:00 2
请写SQL语句将两行IOTYPE相同,时间间隔不足10分钟的第二条记录提取出来。
请大家帮帮忙谢拉1

解决方案 »

  1.   

    IOTYPE相同的话只有两行吗,会不会有以下的情况等等
    Personcode ttime Iotype 
    001        8:00    1 
    001        8:05    1 
    001        8:20    1
    001        12:00   2 
    001        12:00   3
      

  2.   

    select a.* from test a inner join test b on a.iotype = b.iotype
    where datediff(minute,a.ttime,b.ttime) < 10
      

  3.   

    貌似这样不行,,你的ttime不是DateTime类型的,,而且没有日期部分,也不好转成DateTime类型