como mostrar la sumatoria total de mi columna count
Publicado por alexis (1 intervención) el 25/07/2019 19:24:41
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
ALTER procedure [dbo].[web_RepCajasEnviadastotal]
(@dFI as datetime, @dFF as datetime ) as
declare @tRemi table (FechaPicking varchar(50),FechaRemision varchar(50), Remision varchar(50), Picking varchar(50), VIN varchar(50), Num_Sec varchar(50),
Num_Parte varchar(50), Modelo varchar(50), Color varchar(50), Primer varchar(50), XMF varchar(50), GXM varchar(50), CS7 varchar(50), AGP varchar(50),
RBL varchar(50), Descripcion varchar(100), Intervalo varchar(50), Num_Serie varchar(50), Travesaño varchar(50) ,Horas varchar(50))
insert into @tRemi (Picking,VIN,Num_Serie,Remision,FechaPicking)
select PickingId,VIN,CajaId,RemisionId,convert(varchar,SurtidoFecha,120) from EmbarqueSecuencias where RemisionId in (select RemisionId from Remisiones where RemisionFecha between @dFI and @dFF) and Surtido = 1 order by SurtidoFecha asc
update @tRemi
set FechaRemision =convert(varchar,t.RemisionFecha,120)
from (select RemisionId,RemisionFecha from Remisiones where RemisionFecha between @dFI and @dFF) t
where Remision= t.RemisionId
update @tRemi
set Horas = convert(varchar,DATEPART(HOUR,FechaRemision))+':00 a ' + convert(varchar,DATEPART(HOUR,FechaRemision)+1)+':00'
update @tRemi
set Num_Parte = np,Num_Sec=ns,Color=ci,Primer=pn
from
(select VIN vin2,NumeroParte np,NumSecuencia ns,ColorId ci,p.PrimerNombre pn from SecuenciasSPD s left join Primers p on s.PrimerId= p.PrimerId where vin in (select vin from @tRemi)) t
where
vin=vin2
update @tRemi
set Modelo = t.nombre,
Travesaño = t.tr
from
(select c.CajaId ci,me.ModeloEstiloNombre nombre, CodigoRecepcion tr from v_Cajas c
left join v_ModelosEstilos me on c.ModeloEstiloIdFix = me.ModeloEstiloIdFix
where vin in (select vin from @tRemi)) t
where Num_Serie = ci
update @tRemi
set XMF = VentaCodigoId
from
(select vin v,VentaCodigoId from SPDSecuenciaOpciones where vin in (select vin from @tRemi)) t
where VIN = t.v and VentaCodigoId = 'XMF'
update @tRemi
set GXM = VentaCodigoId
from
(select VIN v,VentaCodigoId from SPDSecuenciaOpciones where vin in (select VIN from @tRemi)) t
where VIN = t.v and VentaCodigoId = 'GXM'
update @tRemi
set CS7 = VentaCodigoId
from
(select vin v,VentaCodigoId from SPDSecuenciaOpciones where vin in (select vin from @tRemi)) t
where VIN = t.v and VentaCodigoId = 'CS7'
update @tRemi
set AGP = VentaCodigoId
from
(select vin v,VentaCodigoId from SPDSecuenciaOpciones where vin in (select vin from @tRemi)) t
where VIN = t.v and VentaCodigoId = 'AGP'
update @tRemi
set RBL = VentaCodigoId
from
(select vin v,VentaCodigoId from SPDSecuenciaOpciones where vin in (select vin from @tRemi)) t
where VIN = t.v and (VentaCodigoId = 'MW4' OR VentaCodigoId = 'RBL')
declare @tText table (vin varchar(20),color varchar(50),Modelo varchar(50),XMF varchar(50),GXM varchar(50),CS7 varchar(50),AGP varchar(50),RBL varchar(50),Tot varchar(100))
insert into @tText (vin,color,Modelo,XMF,GXM,CS7,AGP,RBL )
select vin,color,Modelo,XMF,GXM,CS7,AGP,RBL from @tRemi r
update @tText
set XMF = VentaCodigoNombre
from VentaCodigos
where VentaCodigoId = XMF
update @tText
set GXM = VentaCodigoNombre
from VentaCodigos
where VentaCodigoId = GXM
update @tText
set CS7 = VentaCodigoNombre
from VentaCodigos
where VentaCodigoId = CS7
update @tText
set RBL = VentaCodigoNombre
from VentaCodigos
where VentaCodigoId = RBL
update @tText
set AGP = VentaCodigoNombre
from VentaCodigos
where VentaCodigoId = AGP
update @tText
set color = ColorNombre
from Colores
where ColorId = color
update @tText
set Tot = CONCAT(Modelo ,' ', color,' ',XMF,' ',GXM,' ',CS7,' ',AGP )
update @tRemi
set Descripcion = tot
from (select vin v,tot from @tText) t
where VIN = t.v
select Horas, XMF,GXM , CS7, AGP , RBL,count(VIN) as Count
from (
select FechaRemision 'Fecha de la Remision',Remision 'No. de Remision',Picking 'Picking',VIN,Num_Sec 'Secuencia',Num_Parte 'No. Parte',
Modelo,Color,Primer,isnull(XMF,'') XMF,isnull(GXM,'') GXM,isnull(CS7,'') CS7,isnull(AGP,'') AGP,isnull(RBL,'') RBL,Descripcion 'Descripción',
Num_Serie 'No. de Serie', Travesaño 'Travesaño',Horas
from @tRemi
)as datos
group by Horas, XMF,GXM , CS7, AGP , RBL
order by Horas asc
Valora esta pregunta


0