squenda
16-08-2004, 21:55:03
hola a todos, tengo que hacer un concentrado mensual de ingresos por categoria, hice la siguiente sentencia:
select fecha,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'CONSULTA') as CONSULTAS,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'HOSPITALIZACION') as HOSPITALIZACION,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'RX') as RX,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'OTROS') as otros,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'PAGO') as pago
from Historia H1
WHERE
H1.Fecha BETWEEN '08/14/2003' AND '08/14/2004'
order by H1.fecha
el query funciona, el problema es que no filtra por rango de fechas, si alguien me pudiera auxiliar, necesito poder filtrar por un rango de fechas.
Gracias
Saludos
select fecha,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'CONSULTA') as CONSULTAS,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'HOSPITALIZACION') as HOSPITALIZACION,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'RX') as RX,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'OTROS') as otros,
(select sum(Pagado) from Historia H2 where H1.fecha = H2.fecha and H2.categoria = 'PAGO') as pago
from Historia H1
WHERE
H1.Fecha BETWEEN '08/14/2003' AND '08/14/2004'
order by H1.fecha
el query funciona, el problema es que no filtra por rango de fechas, si alguien me pudiera auxiliar, necesito poder filtrar por un rango de fechas.
Gracias
Saludos