表格如下:id time numa 1:00  11
a 2:00  15
..  ...  ..
a 9:00 22
a 10:00 2
a 11:00 20
a 12:00 9
a 13:00 18
.. . ......a 16:00 15
...  b 1:00  8
.  ...  ...
b 9:00 22
b 10:00 2
b 11:00 20
b 12:00 9
b 13:00 18
.. . ......b 16:00 14
.. . ......
c 1:00 11
.. . ......
.. . ......
每小时测量一次数据 
a 和 b 在 9:00--15:00 期间的每一个num 完全相同,但是16:00以后就不相同了,如何判断 a和b 在 9:00-- 16:00这段时间内 num 完全相同?希望得到 
 a 9:00  16:00   
 b 9:00  16:00              
 2000系统 

解决方案 »

  1.   

    没看明白什么意思。猜一个:select *
    from tb a join tb b on a.id=b.id and a.time=b.time and a.num=b.num
      

  2.   

    selet 
      *
    from
      tb t
    where 
      exists(select 1 from tb where time=t.time and num=t.num and time between '9:00' and '16:00')
      

  3.   

    不知道 9:00    16:00 这两个时间点, 就是要 找 a和b 在 某段时间内 num 完全相同
      

  4.   

    try this,select t.id,
    min(t.time) mintime,
    max(t.time) maxtime,
    from
    (select ta.*
    from
    (select * from tab where id='a') ta
    inner join
    (select * from tab where id='b') tb
    on ta.time=tb.time and ta.num=tb.num) t
    group by t.id 
      

  5.   

    必须保证 时间段内是连续的,每一个 num 都相同