日期:2014-05-19  浏览次数:20454 次

各位老手 新手 请帮我 ~ 小弟感激~SQL分组问题
select   d.bmmc,count(a.tsbh),d.bmbh     from
            bk_jyxxb   a   ,bk_tsztb   b,   dz_dzxxb   c,dz_bmxxb   d   group   by   a.jszh     left   join   bk_tsztb   b   on   a.tsbh=b.tsbh   left   join   dz_dzxxb   c   on   a.jszh=c.jszh
          left   join   dz_bmxxb   d   on   c.bmbh=d.bmbh   where   b.tqzt=1   and   (getdate()-yhsj)> 0  
我想让   d.bmmc   和   d.bmbh字段   分组   (相关的信息只显示一条)
运行上面语句后提示   "在关键字   'left '   附近有语法错误。

请各位帮忙~~~

------解决方案--------------------
select d.bmmc,count(a.tsbh),d.bmbh from
bk_jyxxb a ,bk_tsztb b, dz_dzxxb c,dz_bmxxb d group by a.jszh left join bk_tsztb b on a.tsbh=b.tsbh left join dz_dzxxb c on a.jszh=c.jszh
left join dz_bmxxb d on c.bmbh=d.bmbh where b.tqzt=1 and (getdate()-yhsj)> 0
--------------------
你写的我实在是看不懂

select distinct d.bmmc,count(a.tsbh),d.bmbh from
from bk_jyxxb a left join bk_tsztb b on a.tsbh=b.tsbh
left join dz_dzxxb c on a.jszh=c.jszh
left join dz_bmxxb d on c.bmbh=d.bmbh
where b.tqzt=1 and (getdate()-yhsj)> 0
group by d.bmmc 和 d.bmbh