09/02/2010, 10:52
|
| | | Fecha de Ingreso: agosto-2007
Mensajes: 1.338
Antigüedad: 17 años, 5 meses Puntos: 18 | |
Respuesta: Consulta SQL: Convertir columnas en filas Para el primer listado prueba esto:
SELECT 'Feria1' as Feria, Count(Feria1) AS Asistentes
FROM Tabla
GROUP BY Feria1
HAVING Feria1=true
UNION ALL
SELECT 'Feria2' as Feria, Count(Feria2) AS Asistentes
FROM Tabla
GROUP BY Feria2
HAVING Feria2=true
UNION ALL
SELECT 'Feria3' as Feria, Count(Feria3) AS Asistentes
FROM Tabla
GROUP BY Feria3
HAVING Feria3=true
Y para el segundo listado:
SELECT 'Feria1' as Feria,Empresa AS Asistentes
FROM Tabla
WHERE Feria1=true
UNION ALL
SELECT 'Feria2' as Feria,Empresa AS Asistentes
FROM Tabla
WHERE Feria2=true
UNION ALL
SELECT 'Feria3' as Feria,Empresa AS Asistentes
FROM Tabla
WHERE Feria3=true
Un saludo |