tabla simple, query compleja
Publicado por Jomiferdo (2 intervenciones) el 24/10/2011 08:42:37
Hola amigos, tengo un pequeño dolor de cabeza ya con esto, vereis, tengo una tabla muy simple:
http://img38.imageshack.us/img38/5347/tabla.gif
Desde la cual me gustaria generar esta salida.
http://img716.imageshack.us/img716/3529/tablasalida.gif
Lo cierto es que deberia ser simple, pero con la query que he preparado:
no cuenta los que no tienen ni modelo ni firmware,
http://img263.imageshack.us/img263/1306/resultadol.gif
Sin embargo, el dato esta en la tabla, con un simple select lo vemos.
http://img189.imageshack.us/img189/3290/sicuenta.gif
y no veo el problema, si alguien me puede hechar un cable, quedare gratamente agradecido.
http://img38.imageshack.us/img38/5347/tabla.gif
Desde la cual me gustaria generar esta salida.
http://img716.imageshack.us/img716/3529/tablasalida.gif
Lo cierto es que deberia ser simple, pero con la query que he preparado:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
select
case when modelo is null then ' Desconocidos' else modelo end as modelos, firmware,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='01/2011') as Enero,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='02/2011') as Febrero,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='03/2011') as Marzo,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='04/2011') as Abril,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='05/2011') as Mayo,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='06/2011') as Junio,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='07/2011') as Julio,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='08/2011') as Agosto,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='09/2011') as Septiembre,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='10/2011') as Octubre,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='11/2011') as Noviembre,
(select total from estudio_planta_edc edc2 where edc1.modelo=edc2.modelo and edc1.firmware=edc2.firmware and to_char (fecha,'MM/YYYY')='12/2011') as Diciembre
from estudio_planta_edc edc1
where to_char (fecha,'YYYY')>='2011'
no cuenta los que no tienen ni modelo ni firmware,
http://img263.imageshack.us/img263/1306/resultadol.gif
Sin embargo, el dato esta en la tabla, con un simple select lo vemos.
http://img189.imageshack.us/img189/3290/sicuenta.gif
y no veo el problema, si alguien me puede hechar un cable, quedare gratamente agradecido.
Valora esta pregunta


0