我已经写在SQL Server 2008以下联合查询选择数字新列是查询:使用联合查询
select cast(i.AMT_SETT as decimal(10,2)) as AMT_SETT
from DIB_ERECON_INSIGHT_VISA i
union
select NULL as AMT_SETT from DIB_ERECON_TRAN_DETAILS d
where d.channeltype = 'VISA' and cast(fieldno_1 as date) = '18-Apr-2017' and
not exists(
select 1 from DIB_ERECON_INSIGHT_VISA i
where i.STAN= d.fieldno_38 and replace(d.fieldno_39,':','') = i.TIME_LOC_TRAN and
cast(i.Amount as numeric(18,0)) = cast(d.fieldno_31 as numeric(18,0))
)
我得到这个错误:
Error converting data type varchar to numeric.
如果我尝试''
,而不是null
在AMTT_SETT
列第二查询我得到同样的错误
做,如果你执行'UNION'的第一个查询,你得到什么结果呢? –
您的第一条select语句出错,其中一些值是字符串而不是数字 –
您是否发现任何返回0且ISNUMERIC()使用的行? –