SQL Server语句问题(20分)

  • 主题发起人 主题发起人 wanwqing
  • 开始时间 开始时间
W

wanwqing

Unregistered / Unconfirmed
GUEST, unregistred user!
执行如下语句会出错,提示&quot; ) 附近有错误 &quot;,请问如何解决!<br> &nbsp; &nbsp; &nbsp; &nbsp;SQLStr:='SELECT * from (';<br> &nbsp; &nbsp; &nbsp; &nbsp;SQLStr:=SQLStr+'SELECT month(B.dDate) as 月份,0 as 入库金额,sum(A.fPrice*A.fQuantity) as 出库金额 FROM 出货单明细表 as A,出货单表 AS B where (A.iNo=B.iNo) and (year(B.dDate)=:X) group by month(B.dDate)';<br> &nbsp; &nbsp; &nbsp; &nbsp;SQLStr:=SQLStr+'union SELECT month(B.dDate) as 月份,sum(A.fPrice*A.fQuantity) as 入库金额,0 as 出库金额 FROM 进货单明细表 as A,进货单表 AS B where (A.iNo=B.iNo) and (year(B.dDate)=:X) group by month(B.dDate)';<br> &nbsp; &nbsp; &nbsp; &nbsp;SQLStr:=SQLStr+')'; &nbsp; &nbsp;// &nbsp;) 附近有语法错误<br> &nbsp; &nbsp; &nbsp; &nbsp;Query1.SQL.Add(SQLStr);<br> &nbsp; &nbsp; &nbsp; &nbsp;Query1.Params[0].Value:=Edit1.Text;<br> &nbsp; &nbsp; &nbsp; &nbsp;Query1.Open;<br>为了简化问题,在SQL查询分析器中执行如下语句会出错,请问如何解决!<br>use store<br>select * from (select * from 出货单明细表)
 
select * from (select * from 出货单明细表) a <br><br>加个别名就行了
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
605
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部