Operand data type nvarchar is invalid for multiply operator error I am getting this error when I run (this part) of the following query in SQL Management Studio. Can someone help? Do I need to change the query to see this as a different value?

sum(a.UNITCST * a.PRICEQTY) AWP,
sum(a.CLTINGRCST) INGRD_CST,
sum(a.CLTDISPFEE) DF
Some of your fields are text (char) fields, you should use CAST/CONVERT or TRY_CONVERT before to use it on numeric operations.




CREATE TABLE TEST (A VARCHAR(10), B VARCHAR(10), C DECIMAL(18,2));
INSERT INTO TEST VALUES 
('10.2', '20.2', 5.5),
('5.2', '7.4', 10.0);
GO



2 rows affected






SELECT SUM(A * C) F1, 
       SUM(B),
       SUM(C)
FROM   TEST;
GO



Msg 8117 Level 16 State 1 Line 2
Operand data type varchar is invalid for sum operator.






SELECT SUM(TRY_CONVERT(DECIMAL(18,2), A) * C) F1, 
       SUM(TRY_CONVERT(DECIMAL(18,2), B)) F2,
       SUM(C) F3
FROM   TEST;
GO



F1       | F2    | F3   
:------- | :---- | :----
108.1000 | 27.60 | 15.50



dbfiddle here