Azure SQL Database
An Azure relational database service.
5,604 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have been receiving this error.
Msg 8115, Level 16, State 2 Line 182
Arithmetic Overflow Error converting expression to data type int.
Any Help is greatly appreciated
SELECT
ot.Unitname
,LOWER(REPLACE([Unitname],', ',' ')) AS [Location]
,DATEPART(YEAR, (ot.[CheckCloseDateTime])) AS 'Year'
,DATEPART(MONTH, (ot.[CheckCloseDateTime])) AS 'Month'
,DATEPART(DAY, (ot.[CheckCloseDateTime])) AS 'Day'
,DATEPART(HOUR, (ot.[CheckCloseDateTime])) AS 'Hour'
,DATEPART(MINUTE, (dateadd(minute, datediff_big(minute,0,(ot.[CheckCloseDateTime])) / 15 * 15, 0))) AS 'Minute'
,CAST(COUNT(*) * -1 AS BIGINT) AS 'Tables'
,CAST(SUM(COALESCE(NULL,ot.[CheckGrossAmount],0)) AS BIGINT) AS 'Amount'
INTO #Temp5
FROM @InitialChecks ot
GROUP BY
ot.Unitname
,DATEPART(YEAR, (ot.[CheckCloseDateTime]))
,DATEPART(MONTH, (ot.[CheckCloseDateTime]))
,DATEPART(DAY, (ot.[CheckCloseDateTime]))
,DATEPART(HOUR, (ot.[CheckCloseDateTime]))
,DATEPART(MINUTE, (dateadd(minute, datediff_big(minute,0,(ot.[CheckCloseDateTime])) / 15 * 15, 0)))
ORDER BY
ot.Unitname
,'Year'
,'Month'
,'Day'
,'Hour'
,'Minute'