Error when running a query


#1

Hello,

I am getting an issue when I run this query. It is tell me that Arithmetic overflow error converting nvarchar to data type numeric.

Here is a subset of the query I am running as it is long.

CREATE TABLE NeighbourhoodAverages (ID INT IDENTITY (1,1), Village varchar(50), Neighbourhood varchar(50),  Domain nvarchar(max), Question nvarchar(max), Average nvarchar(50), Year nvarchar (50))

INSERT 
INTO NeighbourhoodAverages
	(Village
	, Neighbourhood
	, Question
	, Average
	, Year)
SELECT CONCAT(Village, Setting) AS Village
	, Neighbourhood
	, 'IcanbealonewhenIwish' as QUestion
	, 100.0 *
		Count(Case when CanbealonewhenIwish IN (3.00,4.00)
			THEN 1
			ELSE NULL END) /
		COUNT(*)          AS Average
	, Year
FROM Resident_Survey
Group By Village, Setting, Neighbourhood, Year

I am not running create table everytime I just included that so you could see what the table looks like.

Thanks


#3

what is the datatype of CanbealonewhenIwish?


#4

nvarchar (max). In the table it is being populated as question.


#5

well, in that case you might try

CASE WHEN CanbealonewhenIwish IN ('3.00','4.00')

#6

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.