本帖最后由 luxiaochunyeah 于 2012-06-29 21:07:18 编辑

解决方案 »

  1.   

    where cMATypeCode = '商品通知单' AND bValid = 1
    这个是我从数据库取数据的条件,大家无视
      

  2.   


    --例,此处的@t2相当于你的cdcust_bank
    declare @t1 table(id1 int,id2 int);
    declare @t2 table(id2 int,name varchar(20));
    insert into @t1 select 1,1 union select 2,2
    insert into @t2 select 1,'name1' union select 1,'name2';
    select t1.id1,isnull((select top 1 name from @t2 t2 where t2.id2=t1.id2),'') name from @t1 t1;
      

  3.   

    给个思路:查的时候先group by分组,再找出 count(某个字段)>1的