食品配送公司简介:SQL高手来

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 04:13:00
select * from (select c.PartNo_By PartNo_By,c.ProductName ProductName,b.Coin,round(b.ExcRate,3) ExcRate,
a.UniqueID,a.RefKey,rtrim(a.SrcMsgNo)+'-'+cast(a.SrcMsgType)+'-'+cast(a.SrcItemNo) as SrcMsgNo,a.LineItemNo,PayAmt,Amt,tax,convert(nchar(8),SrcDate,11) xSrcDate,
(select lang01 from comment where f0001='Combo' and f0002='BE2Source' and f0003=a.Source) xSource,
(select lang01 from comment where f0001='UserCombo' and f0002=rtrim(b.CompArea)+'Tax' and f0003=b.TaxCode) xTaxCode from BE2Detail a
join POMaster b on a.SrcMsgNo=b.OrderNo
join PODetail c on b.UniqueID=c.Refkey and a.SrcItemNo=c.LineItemNo) aa

里面有三个错误:
服务器: 消息 1035,级别 15,状态 10,行 2
'cast' 附近有语法错误,需要 'AS'。
服务器: 消息 170,级别 15,状态 1,行 3
第 3 行: 'xSource' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 4
第 4 行: 'xTaxCode' 附近有语法错误。

谁知道怎么改?谢谢

CAST 语法错误,需要加参数 cast(a.SrcMsgType) 要改为 cast(a.SrcMsgType AS 数据类型),其他类似。