有个表a中有字段b 和c 
格式均为 dd,ee,cc.....
求个sql语句 
要求 查询表a中 b字段含有dd,c字段不含有dd的记录的个数

解决方案 »

  1.   

    select count(*) from 表a a where exists(select 1 from 表a where b=dd and c<>dd)
      

  2.   

    select count(*) from 表a where where b=dd and c<>dd
      

  3.   

    字段是格式为dd,ee,ff...的varchar类型 
    就是不知道该怎么写 b字段含有dd而c字段不含有dd 
      

  4.   

    trySELECT COUNT(1) FROM tb WHERE CHARINDEX('dd',b)>0 AND CHARINDEX('dd',c)=0
      

  5.   

    select count(*) from 表a where where b like '%dd%' and c not like '%dd%'
      

  6.   


    select count(*) from a where charindex('dd',b)>0 and charindex('dd',c)<0
      

  7.   

    要求 查询表a中 b字段含有dd,c字段不含有dd的记录的个数
    ==>
    select count(*) as v_count
    from a
    where charindex(',dd,',','+b+',')>0 
    and charindex(',dd,',','+c+',')=0