error Arithmetic overflow error converting expression to data type int.
Publicado por alexis (1 intervención) el 25/07/2019 01:27:53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
ALTER procedure [dbo].[web_ReporteQA_Defectos_Mensual](
@iEstacion int,
@sAlmacenTarget varchar(5)
) as
declare @dFI datetime, @dFF datetime, @iTotal int, @iCurrentDay int
set @dFI ='2016-10-10'
-- set @dFI = GETDATE()
set @iCurrentDay = DATEPART(DAYOFYEAR, @dFI)
set @dFI = CAST(DATEADD(DAY, 1 - @iCurrentDay, @dFI) AS DATE)
set @dFI = DATEADD(hour, 6, @dFI)
set @dFF = DATEADD(YEAR, 1, @dFI)
select @iTotal = count(distinct CajaId)
from DecisionesE120
where DecisionFecha >= @dFI
and DecisionFecha < @dFF
and Estacion = @iEstacion
select top 5 n.Descripcion as Defecto, count(1) * 1000000/ @iTotal as PPMs
from DecisionesE120 d
left join QADefectosEncontrados q on q.DecisionId = d.DecisionId
left join QADefectos n on q.DefectoId = n.DefectoId
where d.DecisionFecha >= @dFI
and d.DecisionFecha < @dFF
AND d.Estacion = @iEstacion
and d.AlmacenId = @sAlmacenTarget
and q.DefectoId is not null
group by Descripcion
order by count(1) desc
Valora esta pregunta


0