我正在尝试构建一个查询,并且卡在这个我收到错误的地方:“将数据类型varchar转换为数字时出错。”
这是代码:
SELECT convert(numeric,convert(decimal(7,4),
(
(SELECT SUM(pn.etiliquido-pn.qtt*pn.epcusto) from pn where (pn.fdata BETWEEN '2016-01-01' AND '2016-06-08') and
(pn.usr1 not like '%'+'Portes'+'%') and (no like '517936') and (pn.epcusto > '0')))
/
(SELECT SUM((pn.etiliquido)) from pn where (pn.fdata BETWEEN '2017-01-01' AND '2017-06-08') and
(pn.usr1 not like '%'+'Portes'+'%') and (no like '517936') and (pn.epcusto > '0')) *100 +'%'))
as Rentabilidade
我正在调用的表中都没有varchar数据,我没有得到我做错了...
答案 0 :(得分:0)