Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » SQL Server »

pivot con doble cabecera

Estas en el tema de pivot con doble cabecera en el foro de SQL Server en Foros del Web. Estimados compañeros del foro: Les agradeceré mucho puedan ayudarme en el siguiente problema: Tengo el siguiente codigo, el cual funciona bien.... DS_PorStatusGerenciasPersonales.SelectCommand = "set language ...
  #1 (permalink)  
Antiguo 26/05/2010, 13:40
 
Fecha de Ingreso: abril-2010
Mensajes: 8
Antigüedad: 14 años
Puntos: 0
Sonrisa pivot con doble cabecera

Estimados compañeros del foro:

Les agradeceré mucho puedan ayudarme en el siguiente problema:

Tengo el siguiente codigo, el cual funciona bien....

DS_PorStatusGerenciasPersonales.SelectCommand = "set language spanish select Gerencia as 'GERENCIAS', [ATENDIDA] as 'ATENDIDAS', [PENDIENTE] as 'PENDIENTES', [ATENDIDA]+[PENDIENTE] as 'TOTAL' FROM(SELECT [Gerencia], [EstadoACR] from ACRS where [FechaIncidente]>=@Del and [FechaIncidente]<=@Al and (TipoEvento='PERSONAL')) as Ref PIVOT (COUNT([EstadoACR]) for [EstadoACR] in([ATENDIDA],[PENDIENTE])) AS pvt ORDER BY pvt.[ATENDIDA]+[PENDIENTE] desc"
DS_PorStatusGerenciasPersonales.SelectParameters(" Del").DefaultValue = DTPDel.SelectedDate
DS_PorStatusGerenciasPersonales.SelectParameters(" Al").DefaultValue = DTPAl.SelectedDate



Pero quiero agregarle 2 columnas mas (INCIDENTE Y ACCIDENTE) de modo que quede como el siguiente ejemplo:


ACCIDENTES INCIDENTES
GERENCIAS TOTALES ATENDIDAS PENDIENTES TOTALES ATENDIDAS PENDIENTES
GIC 3 2 1 5 4 1
GL 2 0 2 7 5 2
CSIPA 4 3 1 4 1 3



De antemano agradezco su apoyo, muchas gracias....
  #2 (permalink)  
Antiguo 26/05/2010, 14:54
 
Fecha de Ingreso: abril-2010
Mensajes: 8
Antigüedad: 14 años
Puntos: 0
Respuesta: pivot con doble cabecera

Cita:
Iniciado por halt60 Ver Mensaje
Estimados compañeros del foro:

Les agradeceré mucho puedan ayudarme en el siguiente problema:

Tengo el siguiente codigo, el cual funciona bien....

DS_PorStatusGerenciasPersonales.SelectCommand = "set language spanish select Gerencia as 'GERENCIAS', [ATENDIDA] as 'ATENDIDAS', [PENDIENTE] as 'PENDIENTES', [ATENDIDA]+[PENDIENTE] as 'TOTAL' FROM(SELECT [Gerencia], [EstadoACR] from ACRS where [FechaIncidente]>=@Del and [FechaIncidente]<=@Al and (TipoEvento='PERSONAL')) as Ref PIVOT (COUNT([EstadoACR]) for [EstadoACR] in([ATENDIDA],[PENDIENTE])) AS pvt ORDER BY pvt.[ATENDIDA]+[PENDIENTE] desc"
DS_PorStatusGerenciasPersonales.SelectParameters(" Del").DefaultValue = DTPDel.SelectedDate
DS_PorStatusGerenciasPersonales.SelectParameters(" Al").DefaultValue = DTPAl.SelectedDate



Pero quiero agregarle 2 columnas mas (INCIDENTE Y ACCIDENTE) de modo que quede como el siguiente ejemplo:

Cita:
ACCIDENTES INCIDENTES
GERENCIAS TOTALES ATENDIDAS PENDIENTES TOTALES ATENDIDAS PENDIENTES
GIC 3 2 1 5 4 1
GL 2 0 2 7 5 2
CSIPA 4 3 1 4 1 3

De antemano agradezco su apoyo, muchas gracias....

Etiquetas: doble, pivot, cabeceras
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:51.