Hi Experts,
while executing the below query error showing.
"Conversion failed when converting the nvarchar value 'YES' to data type int"
SELECT T0.[DocEntry]
,T0.[DocNum]
,T0.[DocDate]
, T0.[CardCode]
, T0.[CardName]
,T0.[Comments]
, T0.[DocTotal]
, T0.[DocTotal] - T0.[VatSum] AS 'Sales Value'
, T0.[DocTotal] - T0.[VatSum] - T0.[GrosProfit] AS 'Purchase Costs'
,CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END AS 'Air frieght'
,CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END AS 'Inland Charges'
,CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END AS 'Duty'
, T0.[DocTotal] - T0.[VatSum] - T0.[GrosProfit] +
CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END
+ CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END
+ CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END
AS 'Total Costs'
, T0.[GrosProfit] -
CASE
WHEN T0.[U_Airfrieght] IS NULL THEN 0
ELSE T0.[U_Airfrieght]
END
- CASE
WHEN T0.[U_InlandCharges] IS NULL THEN 0
ELSE T0.[U_InlandCharges]
END
- CASE
WHEN T0.[U_Duty] IS NULL THEN 0
ELSE T0.[U_Duty]
END
AS 'Gross Profit'
FROM OINV T0 WHERE T0.[DocDate] between '10-01-2021' and '10-31-2021'