select count(1),col006 from table1 where not exist(select 1 from table1 where coloo1=table1.coloo1) and table1.col007 = '123'
错了 改下: select count(1),col006 from table1 where not exist(select 1 from table2 where coloo1=table1.coloo1) and table1.col007 = '123'
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
这样改下:
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
select count(1),col006 from table1 where not exist(select 1 from table2 where coloo1=table1.coloo1) and table1.col007 = '123'
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
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