SELECT distinct s.F_sbmc,
s.F_sbbh,
s.F_sbxh,
s.f_ks,
s.autoid,
count(s.f_sbmc ) as shuliang
FROM (select * from HOSPITAL_SBJBK as a left join hospital_sbwxb as b on a.autoid =b.autoid left
join hospital_sbhtjd as c on b.f_sbmc =c.f_sbmc left join hospital_sbxcb as d
on b.f_sbmc =d.f_sbmc ) s, --你要选择是一个表中,加了select * from ,还有括号
(select count( t.id ) as jiandu,t.F_sbmc from hospital_sbhtjd ,
hospital_sbwxht p where t.f_htid =p.f_htid and t.f_sbmc and --t.f_sbmc明显不对,多了and,自己改
t.jdrq between '2005-11-01' and '2005-12-31' group by t.F_sbmc) f
where s.if_yn ='3' and s.wxrq between '2005-11-01' and '2005-12-31' and
s.F_SBMC=f.F_sbmc
group by
s.F_sbmc,
s.F_sbbh,
s.F_sbxh,
s.f_ks,
s.autoid
--注意多表联合后的基本结构
s.F_sbbh,
s.F_sbxh,
s.f_ks,
s.autoid,
count(s.f_sbmc ) as shuliang
FROM (select * from HOSPITAL_SBJBK as a left join hospital_sbwxb as b on a.autoid =b.autoid left
join hospital_sbhtjd as c on b.f_sbmc =c.f_sbmc left join hospital_sbxcb as d
on b.f_sbmc =d.f_sbmc ) s, --你要选择是一个表中,加了select * from ,还有括号
(select count( t.id ) as jiandu,t.F_sbmc from hospital_sbhtjd ,
hospital_sbwxht p where t.f_htid =p.f_htid and t.f_sbmc and --t.f_sbmc明显不对,多了and,自己改
t.jdrq between '2005-11-01' and '2005-12-31' group by t.F_sbmc) f
where s.if_yn ='3' and s.wxrq between '2005-11-01' and '2005-12-31' and
s.F_SBMC=f.F_sbmc
group by
s.F_sbmc,
s.F_sbbh,
s.F_sbxh,
s.f_ks,
s.autoid
--注意多表联合后的基本结构
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货