I am facing an error on my SQL script:
Arithmetic overflow error converting numeric to data type numeric
select x.MemberName,x.DOB,x.FilePath,x.Medication,x.NDC,x.Directions,x.Name,x.Strength,x.GenericName,x.QtyOrdered,x.DaysSupply,x.DateFilled,
CASE
WHEN x.test = 0 THEN 'N/A'
WHEN compliance > 100.0 THEN '100.0'
ELSE CONVERT(VARCHAR(5), CAST(FLOOR(compliance *10)/10.0 AS DECIMAL(3,1)))
END as [Compliance]
I am facing the error on just above syntax line.
Here’s your problem:
Throws “Arithmetic overflow error converting numeric to data type numeric” error. Changing to
DECIMAL(4,1)works, or as @paola suggests, change your condition to>= 100.0In your case
decimal(3, 1)means a total of 3 digits with 1 digit to the right of the decimal point,whereas
decimal(4,1)provides a total of 4 digits with 1 digit to the right of the decimal point,