Получило это сообщение об ошибке при выполнении запроса ниже: '' Преобразование не удалось при преобразовании значения varchar '1114.66000' в тип данных int. "
select
P.VENDORID Vendor_ID,
V.VENDNAME Vendor_Name,
V.VNDCHKNM Vendor_Check_Name,
case P.PYENTTYP
when 0 then 'Check'
when 1 then 'Cash'
when 2 then 'Credit Card'
when 3 then 'EFT'
else 'Other'
end Payment_Type,
case when P.PYENTTYP in (0,1,3) then P.CHEKBKID
else '' end Checkbook_ID,
case P.PYENTTYP when 2 then P.CARDNAME
else '' end Credit_Card_ID,
P.DOCDATE Payment_Date,
P.PSTGDATE Payment_GL_Date,
P.VCHRNMBR Payment_Voucher_Number,
P.DOCNUMBR Payment_Document_Number,
P.DOCAMNT Payment_Functional_Amount,
P.TRXDSCRN Payment_Description,
coalesce(PA.APTVCHNM,'') Apply_To_Voucher_Number,
case PA.APTODCTY
when 1 then 'Invoice'
when 2 then 'Finance Charge'
when 3 then 'Misc Charge'
else ''
end Apply_To_Doc_Type,
coalesce(PA.APTODCNM,'') Apply_To_Doc_Number,
coalesce(PA.APTODCDT,'1/1/1900') Apply_To_Doc_Date,
coalesce(PA.ApplyToGLPostDate,'1/1/1900') Apply_To_GL_Date,
coalesce(AD.DUEDATE,'1/1/1900') Apply_To_Due_Date,
coalesce(PA.APPLDAMT,0) Applied_Amount,
coalesce(PA.DISTKNAM,0) Discount_Amount,
coalesce(AD.TRXDSCRN,'') Apply_To_Doc_Description
из (выберите VENDORID, DOCTYPE, DOCDATE, VCHRNMBR, DOCNUMBR, DOCAMNT, VOIDED, TRXSORCE, CHEKBKID, PSTGDATE, PYENTTYP, CARDNAME, TRXDSCRN из объединения PM30200 выберите VENDORID, DOCD, DOCNDBRT, DOCAMDRK, DOCAMDT, DOCAMDT PSTGDATE, PYENTTYP, CARDNAME, TRXDSCRN от PM20000) P
inner join PM00200 V
on P.VENDORID = V.VENDORID
left outer join
(select VENDORID, VCHRNMBR, DOCTYPE, APTVCHNM, APTODCTY,
APTODCNM, APTODCDT, ApplyToGLPostDate, APPLDAMT, DISTKNAM
from PM30300
union
select VENDORID, VCHRNMBR, DOCTYPE, APTVCHNM, APTODCTY,
APTODCNM, APTODCDT, ApplyToGLPostDate, APPLDAMT, DISTKNAM
from PM30300) PA
on P.VCHRNMBR = PA.VCHRNMBR and P.VENDORID = PA.VENDORID
and P.DOCTYPE = PA.DOCTYPE
left outer join -- added for due date
(select DOCTYPE, VCHRNMBR, DUEDATE, TRXDSCRN )
from PM30200
union
select DOCTYPE, VCHRNMBR, DUEDATE, TRXDSCRN
с PM20000) AD на PA.APTODCTY = AD.DOCTYPE и PA.APTVCHNM = AD.VCHRNMBR, где P.DOCTYPE = 6 и P.VOIDED = 0