I have the following sql query code and I can not get to execute the desired output.
SELECT Deal_type, Price_type,
cast(sum(Deal_type)/count(Deal_type)*1.0 as decimal(12,2)) as results
FROM [dbo].[all]
WHERE Deal_type in ('RMBS','abs', 'cmbs', 'clo', 'cdo')
GROUP BY Deal_type,Price_type order by Deal_type
I am trying to display the percentage values in decimal and currently its displaying the error message -
Operand data type nvarchar is invalid for sum operator.
Any help with the above query would be very much appreciated.

'RMBS' + 'abs'? Becausesum()does exactly this - that is, it does not, because it doesn't know what to do. (Reading for the second time: do you want to get the percentage of 'RMBS' rows of all ('RMBS','abs', 'cmbs', 'clo', 'cdo') rows?) – dezso Feb 26 at 10:09