我已經寫在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()使用的行? –