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

Problemas Con Count() Sql Server 2005?

Estas en el tema de Problemas Con Count() Sql Server 2005? en el foro de SQL Server en Foros del Web. TENGO MI TABLA DE PERSONAS CON UN CAMPO LLAMADO GENERO, EN LA TABLA ALMACENO CUANDO ES MASCULINO UN 0 Y CUANDO ES FEMENINO UN 1, ...
  #1 (permalink)  
Antiguo 17/06/2008, 10:37
 
Fecha de Ingreso: mayo-2008
Mensajes: 27
Antigüedad: 16 años
Puntos: 0
Problemas Con Count() Sql Server 2005?

TENGO MI TABLA DE PERSONAS CON UN CAMPO LLAMADO GENERO, EN LA TABLA ALMACENO CUANDO ES MASCULINO UN 0 Y CUANDO ES FEMENINO UN 1, QUIERO SABER CUANTOS SON 0 Y CUANTOS SON 1 EN UNA MISMA CONSULTA, SE QUE ES ALGO FACIL PERO NO LOGRO MI OBJETIVO, GRACIAS
  #2 (permalink)  
Antiguo 17/06/2008, 10:47
Avatar de Andres95
Colaborador
 
Fecha de Ingreso: diciembre-2004
Mensajes: 1.802
Antigüedad: 19 años, 5 meses
Puntos: 38
Respuesta: Problemas Con Count() Sql Server 2005?

Código:
Select  sum(Case Genero  When 0 Then 1 Else 0 End ) CuentaMasculino
       ,sum(Case Genero  When 1 Then 1 Else 0 End ) CuentaFemenino
From MiTabla
Saludos!
__________________
La sencillez y naturalidad son el supremo y último fin de la cultura...
--
MCTS : SQL Server 2008, .NET Framework 3.5, ASP.NET Applications.
  #3 (permalink)  
Antiguo 17/06/2008, 11:03
 
Fecha de Ingreso: mayo-2008
Mensajes: 27
Antigüedad: 16 años
Puntos: 0
Respuesta: Problemas Con Count() Sql Server 2005?

TAL COMO LO QUERIA, MUCHAS GRACIAS!!
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 04:43.