不等了,自己解决吧!select Ttemp.jh,case when Ttemp.xyz=0 and tc.k is null then 0 else 1 end bbb from
(select ta.m as jh,case when tb.n is null then 1 else 0 end xyz from ta
 left join tb on ta.m=tb.n)Ttemp left  join tc on Ttemp.jh=tc.k请接分!

解决方案 »

  1.   

    create table #Ta (m char)
    create table #Tb (n char)
    create table #Tc (k char)
    go
    insert into #Ta values('a')
    insert into #Ta values('b')
    insert into #Ta values('c')
    insert into #Ta values('d')
    insert into #Ta values('e')
    insert into #Ta values('f')
    insert into #Ta values('g')
    insert into #Ta values('h')
    insert into #Ta values('i')
    go
    insert into #Tb values('a')
    insert into #Tb values('b')
    insert into #Tb values('c')
    go
    insert into #Tc values('c')
    insert into #Tc values('e')
    insert into #Tc values('f')
    insert into #Tc values('h')
    go
    /*简而言之,就是Tb中没有的为1,Tb中有但Tc中没有的为 0,Tb中有且Tc中有的为1)*/select m,'xyz'=case when m not in (select n from #Tb)  then 1 
                when m in (select n from #Tb) and m not in (select k from #Tc) then 0
        when m in (select n from #Tb) and m in (select k from #Tc) then 1
    end 
    from #Ta