--try select count(A.Company) from A where A.ID not in (select distinct B.id from B ) group by A.company
--上面是A得id不再B中出现得。
如果是B得id不在A中出现得那么。只能统计总数,而不能根据A得company来分组。因为无法关联。 以下是B得id不在A中得不同得id得总数。 select count(distinct id) from B where id not in(select id from A)
select company ,count(1) as '数量' from A where not exists(select 1 from B where ID=A.ID) group by company
我现在要列出B表中ID不曾在A表中出现的记录,并且A表有一字段Company,查询结果是要group by Company的,并显示每一个Company所拥有这样记录的数量! ---------------我现在要列出B表中ID不曾在A表中出现的记录, ID 不曾在A表中出现的记录, 不就代表着.在A表中没有,那不就代表着 a表中的company 也不会有?
select count(A.Company) from A
where A.ID not in (select distinct B.id from B )
group by A.company
以下是B得id不在A中得不同得id得总数。
select count(distinct id)
from B
where id not in(select id from A)
,count(1) as '数量'
from A
where not exists(select 1 from B where ID=A.ID)
group by company
Company的,并显示每一个Company所拥有这样记录的数量!
---------------我现在要列出B表中ID不曾在A表中出现的记录, ID 不曾在A表中出现的记录, 不就代表着.在A表中没有,那不就代表着 a表中的company 也不会有?