Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2010, 14:43
halt60
 
Fecha de Ingreso: abril-2010
Mensajes: 8
Antigüedad: 14 años, 11 meses
Puntos: 0
agregar columnas en consulta con pivot

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



Código HTML:
                     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
 
Pero quiero agregarle 2 columnas mas (INCIDENTE Y ACCIDENTE) de modo que quede como el siguiente ejemplo:

Última edición por halt60; 04/06/2010 a las 14:50