10/02/2012, 08:48
|
| Colaborador | | Fecha de Ingreso: agosto-2006 Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 3 meses Puntos: 774 | |
Respuesta: ejercicio SQL porfa ! no entiendo como realizarlo Cita:
Iniciado por antoninerin Otra solución:
select COUNT(*) as '0 - 10',
(select COUNT(*) FROM tabla where Anys between 11 and 20) as '11 - 20',
(select COUNT(*) FROM tabla where Anys between 21 and 30) as '21 - 30',
(select COUNT(*) FROM tabla where Anys between 31 and 40) as '31 - 40',
(select COUNT(*) FROM tabla where Anys between 41 and 50) as '41 - 50',
(select COUNT(*) FROM tabla where Anys between 51 and 60) as '51 - 60',
(select COUNT(*) FROM tabla where Anys between 61 and 70) as '61 - 70',
(select COUNT(*) FROM tabla where Anys between 71 and 80) as '71 - 80',
(select COUNT(*) FROM tabla where Anys between 81 and 90) as '81 - 90',
(select COUNT(*) FROM tabla where Anys > 90) as 'Altres',
(select COUNT(*) FROM tabla) as 'Total'
FROM tabla
where Anys between 0 and 10 Buena respuesta amigo pero estas usando un subquery muchas veces que puedes evitar con un case(que para eso existe).
Saludos!
__________________ What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me |