
25/05/2010, 20:15
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 26
Antigüedad: 14 años, 11 meses Puntos: 0 | |
Respuesta: ayudenme a solucionar este problema O.k este es el codigo k estoy tratando de ejecutar, y la version de mysql es la 5.1.37
Código:
DELIMITER $$
CREATE PROCEDURE `sivipcan`.`spRptIvaa_municipio`(pIdUnidad CHAR(2),pDateUno DATETIME, pDateDos DATETIME)
BEGIN SELECT papsAntUno, papsAntDos, papsAntTres, papsAntCuatro, papsAntCinco, ivaaUno,
ivaaUnoPR, ivaaUnoNR, ivaaUnoMedico, ivaaUnoEnf, ivaaUnoAux, ivaaUnoEsp, ivaaUnoCA,
crioUno, asaTermUno, referidaUno, AStxUno, ivaaDos, ivaaDosPR, ivaaDosNR, ivaaDosMedico,
ivaaDosEnf, ivaaDosAux, ivaaDosEsp, ivaaDosCA,crioDos,asaTermDos, referidaDos,
AStxDos,ivaaTres, ivaaTresPR, ivaaTresNR, ivaaTresMedico, ivaaTresEnf,ivaaTresAux,
ivaaTresEsp,ivaaTresCA, crioTres, asaTermTres, referidaTres, AStxTres, ivaaCuatro,
ivaaCuatroPR,ivaaCuatroNR,ivaaCuatroMedico, ivaaCuatroEnf, ivaaCuatroAux, ivaaCuatroEsp,
ivaaCuatroCA,crioCuatro,asaTermCuatro, referidaCuatro, AStxCuatro, ivaaCinco, ivaaCincoPR,
ivaaCincoNR,ivaaCincoMedico,ivaaCincoEnf,ivaaCincoAux,ivaaCincoEsp, ivaaCincoCA,
crioCinco,asaTermCinco, referidaCinco, AStxCinco FROM
(SELECT (SELECT COUNT(*) FROM (SELECT n_expediente FROM vw_rpt_ivaa
WHERE id_tipo_examen = 1 AND edad_paciente > 24 AND edad_paciente < 30 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos) AS tblPapsUno) AS papsAntUno,
(SELECT COUNT(*) FROM (SELECT n_expediente FROM vw_rpt_ivaa
WHERE id_tipo_examen = 1 AND edad_paciente > 29 AND edad_paciente < 35 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos) AS tblPapsDos) AS papsAntDos,
(SELECT COUNT(*) FROM (SELECT n_expediente FROM vw_rpt_ivaa
WHERE id_tipo_examen = 1 AND edad_paciente > 34 AND edad_paciente < 40 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos) AS tblPapsTres) AS papsAntTres,
(SELECT COUNT(*) FROM (SELECT n_expediente FROM vw_rpt_ivaa
WHERE id_tipo_examen = 1 AND edad_paciente > 39 AND edad_paciente < 45 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos) AS tblPapsCuatro) AS papsAntCuatro,
(SELECT COUNT(*) FROM (SELECT n_expediente FROM vw_rpt_ivaa
WHERE id_tipo_examen = 1 AND edad_paciente > 45 AND edad_paciente < 50 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos) AS tblPapsCinco) AS papsAntCinco,
(SELECT COUNT(*)FROM (SELECT n_expediente, COUNT(*) FROM vw_rpt_ivaa WHERE id_tipo_examen = 2
AND edad_paciente > 24 AND edad_paciente < 30 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos GROUP BY n_expediente HAVING count(*) < 2 AND
COUNT(*) > 0) AS tblIvaaUno) AS ivaaUno,
(SELECT COUNT(*)FROM (SELECT n_expediente, COUNT(*) FROM vw_rpt_ivaa WHERE id_tipo_examen = 2
AND edad_paciente > 24 AND edad_paciente < 30 AND id_pos_resultado = 58 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos GROUP BY n_expediente HAVING count(*) < 2 AND
COUNT(*) > 0) AS tblIvaaUnoPR) AS ivaaUnoPR,
(SELECT COUNT(*)FROM (SELECT n_expediente, COUNT(*) FROM vw_rpt_ivaa WHERE id_tipo_examen = 2
AND edad_paciente > 24 AND edad_paciente < 30 AND id_pos_resultado = 59 AND id_municipio = pIdUnidad AND
fecha_examen BETWEEN pDateUno AND pDateDos GROUP BY n_expediente HAVING count(*) < 2 AND
COUNT(*) > 0) AS tblIvaaUnoNR) AS ivaaUnoNR,
(SELECT COUNT(*)FROM (SELECT n_expediente, COUNT(*) FROM vw_rpt_ivaa WHERE id_tipo_examen = 2
AND edad_paciente > 24 AND edad_paciente < 30 AND id_municipio = pIdUnidad AND
id_cargo = 6 OR id_cargo = 7 AND fecha_examen BETWEEN pDateUno AND pDateDos GROUP BY n_expediente HAVING count(*) < 2 AND
COUNT(*) > 0) AS tblIvaaUnoMedico) AS ivaaUnoMedico,
(SELECT COUNT(*)FROM (SELECT n_expediente, COUNT(*) FROM vw_rpt_ivaa WHERE id_tipo_examen = 2
AND edad_paciente > 24 AND edad_paciente < 30 AND id_municipio = pIdUnidad AND
id_cargo = 5 AND fecha_examen BETWEEN pDateUno AND pDateDos GROUP BY n_expediente HAVING count(*) < 2 AND
COUNT(*) > 0) AS tblIvaaUnoEnf) AS ivaaUnoEnf
y falta aun mas pero por espacio no pude agregarlo y es k es enorme |