select count(a.fr) as num,b.frname from a,b where a.fr= b.fr_id group by b.frname
select count(a.fr) as num,b.frname from a,b where a.fr= b.fr_id group by b.frname
select (select b.frname from b where fr= a.fr_id ) as frname, count(a.RZInfor_id) as num from a group by a.fr_id 或 select b.frame, count(a.RZInfor_id) as num from a inner join a on a.fr= b.fr_id group by b.frame
select count(a.RZInfor_id) as num, b.frname from a,b where a.fr=b.fr group by franme
select count(a.RZInfor_id) as num, b.frname from a join b on a.fr=b.fr group by b.franme
不能用franme因为franme不为主键可能重复,iewzhao(葳蕤) 的 select (select b.frname from b where fr= a.fr_id ) as frname, count(a.RZInfor_id) as num from a group by a.fr_id 正确
Select b.frame,aa.num From (Select fr,count(RZInfor_id) as num from a group by fr) aa join b on aa.fr = b.fr_id
select a.*,b.frname from ( select fr,count(RZInfor_id) as num from a group by fr ) a inner join b on a.fr= b.fr_id
where a.fr= b.fr_id group by b.frname
where a.fr= b.fr_id group by b.frname
count(a.RZInfor_id) as num
from a
group by a.fr_id
或
select b.frame,
count(a.RZInfor_id) as num
from a
inner join a on a.fr= b.fr_id
group by b.frame
where a.fr=b.fr
group by franme
on a.fr=b.fr
group by b.franme
select (select b.frname from b where fr= a.fr_id ) as frname,
count(a.RZInfor_id) as num
from a
group by a.fr_id
正确
(Select fr,count(RZInfor_id) as num from a group by fr) aa
join b on aa.fr = b.fr_id
(
select fr,count(RZInfor_id) as num
from a
group by fr
) a
inner join b
on a.fr= b.fr_id