日期:2014-05-17  浏览次数:21017 次

在SQLSERVER中正常但是在ASP中不正常
SQL语句是:select   sum(rzbf)   rzbf,sum(ysbf)   ysbf,sum(ssbf)   ssbf   from   (select   sum(hjbf)   rzbf,sum(hjysbf)   ysbf,sum(hjssbf)   ssbf   from   h_cbtz   where   1=1   and   jbr   in   ( '005011 ')   group   by   polno   having   sum(hjysbf)!=0   and   max(jfrq)   between   '9/11/2006 '   and   '10/11/2006 ')

在SQLSERVER中尝试运行没有任何问题,但是在ASP中运行后却报

Microsoft   OLE   DB   Provider   for   SQL   Server   错误   '80040e14 '  

Line   1:   Incorrect   syntax   near   ') '.  

/tj/yshou/yshou.asp,行   154

错误,请大家帮忙看看,ASP语句没有问题,我把SQL换成
select   sum(hjbf)   rzbf,sum(hjysbf)   ysbf,sum(hjssbf)   ssbf   from   h_cbtz   where   1=1   and   jbr   in   ( '005011 ')   group   by   polno   having   sum(hjysbf)!=0   and   max(jfrq)   between   '9/11/2006 '   and   '10/11/2006 '

就很正常(当然这个结果不是我想要的结果,我想要的效果是上条SQL的执行结果),真奇怪,请大家帮忙,谢谢。

------解决方案--------------------
你这两个sql并不是同一样. 错误的原因是子查询没有指定别名. try: select sum(AA.rzbf) rzbf,sum(AA.ysbf) ysbf,sum(AA.ssbf) ssbf from ( select sum(hjbf) rzbf, sum(hjysbf) ysbf, sum(hjssbf) ssbf from h_cbtz where 1=1 and jbr in ( '005011 ') group by polno having sum(hjysbf)!=0 and max(jfrq) between '9/11/2006 ' and '10/11/2006 ') AS AA