比如说某个表ta中有三列 时间,地点,事件
假如数据为
             01012008,a,b
             02012008,a,b
             03012008,a,b
             01012008,b,c
             02012008,b,c
             03012008,b,c
             04012008,b,c
             01012008,a,c
             02012008,a,c
             03012008,a,c
             04012008,a,c 
怎样查找没有包含04012008这个时间的地点和事件?也就是a,b这个数据怎么把它找出来?
select 地点,事件
from ta
where 时间 ?

解决方案 »

  1.   

    没包括刚才看错了
    where 时间<>'04012008'
      

  2.   

    try
    create table oo(a varchar(20),b varchar(20),c varchar(20))
    insert oo
    select '01012008','a','b'
    union all
    select '02012008','a','b'
    union all
    select '04012008','a','c 'select a, b+c from oo  group by b+c,a having a<>'04012008'
      

  3.   

    select 地点,事件 --加distinct 
    from ta 
    where 时间    
    <>'04012008' and 地点+'__'+事件 not in (select 地点+'__'+事件 from ta where 时间='04012008')
      

  4.   


    select 地点,事件 
    from ta 
    where 时间  not in(....)
      

  5.   

    create table #t(a varchar(20),b varchar(20),c varchar(20))
    insert #t
    select '01012008','a','b'
    union all
    select '02012008','a','b'
    union all
    select '04012008','a','c 'select a, b+c from #t group by a,b+c having a<>'04012008'
      

  6.   

    支持ChinaJiaBing的观点,楼主可以先试验下
      

  7.   

    ChinaJiaBing 不对
    wgzaaa的貌似还可以,不过我后来随便试了试,后两列如果是数据型怎么写?
      

  8.   

    那就转有字符型的了convert 呵呵