各位大哥们!!有问题请教!!!

tyrblggj 2005-11-20 10:04:01
SELECT distinct s.F_sbmc,
s.F_sbbh,
s.F_sbxh,
s.f_ks,
s.autoid,
count(s.f_sbmc ) as shuliang
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 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.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


这是我写的SQL语句,可是运行总是提示错误,错误提示如下:

服务器: 消息 170,级别 15,状态 1,行 7
第 7 行: 's' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 10
第 10 行: 'f' 附近有语法错误。
...全文
62 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
点点星灯 2005-11-20
  • 打赏
  • 举报
回复
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


--注意多表联合后的基本结构

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧