SELECT COUNT(*),COL006 FROM TABLE1 T WHERE NOT EXISTS(SELECT 1 FROM TABLE2 WHERE COL001=T.COL001) AND COL007='123'

解决方案 »

  1.   

    select count(1),col006 from table1  where not exist(select 1 from table1 where coloo1=table1.coloo1) and table1.col007 = '123'
      

  2.   

    错了 改下:
    select count(1),col006 from table1  where not exist(select 1 from table2 where coloo1=table1.coloo1) and table1.col007 = '123'
      

  3.   


    select count(table1.col006), table1.col006
    from table1  right join table2 on table1.col001 = table2.col001
    where table1.col001 is null  and table1.col007 = '123'
    group by table1.col006
      

  4.   

    这样改下:
     
    SELECT count(table1.col006), table1.col006
    FROM TABLE1 WHERE TABLE1.COL007 = '123' AND 
    TABLE1.COL001 NOT IN (SELECT DISTINCT TABLE2.COL001 FROM TABLE2)
    GROUP BY TABLE1.COL006